diff options
author | Gregory P. Smith <greg@krypto.org> | 2013-04-30 01:03:46 -0700 |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2013-04-30 01:03:46 -0700 |
commit | f4a81018278410a686c152f5d77704b66a44e858 (patch) | |
tree | 1c9cc0c9c8c73f59ccc0483a86d571ce8722f318 /Python/pythonrun.c | |
parent | f6eb3e9ba97d7489f84b9bc202c64c6b5022857f (diff) | |
parent | 1a46c427590ebe60b8c1befc08576558bcf23dae (diff) | |
download | cpython-f4a81018278410a686c152f5d77704b66a44e858.tar.gz |
merge
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 |