diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2013-04-17 04:10:51 +0300 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2013-04-17 04:10:51 +0300 |
commit | 70a8ea77c7543278deea1cb037b63fb9a8cc00a2 (patch) | |
tree | 3a391c60aa34a293c073b6a86cd7eb5b34b149c8 /Python/pythonrun.c | |
parent | a0ffad2142f1c33f32c35bbda2d0333a7568988b (diff) | |
parent | 5d00bcd6ca476d6f34c5fb2eebf49614e57ccfaa (diff) | |
download | cpython-70a8ea77c7543278deea1cb037b63fb9a8cc00a2.tar.gz |
#17740: merge with 3.3.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index dd32017574..751008ac30 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -35,12 +35,29 @@ #define PATH_MAX MAXPATHLEN #endif +#ifdef Py_REF_DEBUG +void _print_total_refs() { + 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 |