diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-05-04 15:16:16 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-05-04 15:16:16 +0300 |
commit | f6489f253d245dc5cb21dda02c45c86f3c8d3881 (patch) | |
tree | 10a64e9797485122573d04139645cd944f69f110 /Python/pythonrun.c | |
parent | aa893cdf2a636fb570676fb9ecb60f89fdfb8b04 (diff) | |
parent | 6b8ee7dacf9c2296302744dca00887eab479e07a (diff) | |
download | cpython-f6489f253d245dc5cb21dda02c45c86f3c8d3881.tar.gz |
Null merge (already committed in changeset a3ba5fe9bfd3)
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 |