summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-04-21 16:59:04 -0400
committerR David Murray <rdmurray@bitdance.com>2013-04-21 16:59:04 -0400
commita54629ec12fd6cc28816eb7ef0c392f9555c270e (patch)
treee6773accc248dccc21ee52aac065fb9d948d35cb /Python/pythonrun.c
parent392e3ef58618581d283858c2a3ce8d83e1c4ae6e (diff)
parentf97ac088edd09db53d72485714f3b68d3a2625eb (diff)
downloadcpython-a54629ec12fd6cc28816eb7ef0c392f9555c270e.tar.gz
#15575: Clarify tutorial description of when modules are executed.
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