diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2013-04-30 16:34:30 +0300 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2013-04-30 16:34:30 +0300 |
commit | c6666f2ecc6dfd60aa6fe88950c5dfb2eb8d6687 (patch) | |
tree | d32b1b16efb870f6f89d2b7cced40620296efa00 /Python/pythonrun.c | |
parent | 14a057272cda4f9703954afaa0156517bb0b321f (diff) | |
parent | 2ee4b800e8fc729e008e576bd7e12aa1c0935098 (diff) | |
download | cpython-c6666f2ecc6dfd60aa6fe88950c5dfb2eb8d6687.tar.gz |
#17881: merge with 3.3.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index ee6071e631..b92a8bd9b4 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -35,12 +35,30 @@ #define PATH_MAX MAXPATHLEN #endif +#ifdef Py_REF_DEBUG +static +void _print_total_refs(void) { + PyObject *xoptions, *key, *value; + xoptions = PySys_GetXOptions(); + if (xoptions == NULL) + return; + key = PyUnicode_FromString("showrefcount"); + if (key == NULL) + return; + value = PyDict_GetItem(xoptions, key); + Py_DECREF(key); + if (value == Py_True) + fprintf(stderr, + "[%" PY_FORMAT_SIZE_T "d refs, " + "%" PY_FORMAT_SIZE_T "d blocks]\n", + _Py_GetRefTotal(), _Py_GetAllocatedBlocks()); +} +#endif + #ifndef Py_REF_DEBUG #define PRINT_TOTAL_REFS() #else /* Py_REF_DEBUG */ -#define PRINT_TOTAL_REFS() fprintf(stderr, \ - "[%" PY_FORMAT_SIZE_T "d refs]\n", \ - _Py_GetRefTotal()) +#define PRINT_TOTAL_REFS() _print_total_refs() #endif #ifdef __cplusplus |