summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-04-19 05:38:48 +0300
committerEzio Melotti <ezio.melotti@gmail.com>2013-04-19 05:38:48 +0300
commit3c7213203e79485de5e5e7bf78454dfe336f98d2 (patch)
tree3ea4203d0d9adde32e804b2edcdc7c610652c18d /Python/pythonrun.c
parentc9d1a4da3d816be9ac676f5f0c2f15c7c5fe6c24 (diff)
parent7a8ad8b815d63bc2359144e2d988bf42a11e008e (diff)
downloadcpython-3c7213203e79485de5e5e7bf78454dfe336f98d2.tar.gz
#17779: merge with 3.3.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c23
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