summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2017-09-12 00:59:22 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-09-12 00:59:22 (GMT)
commit8728018624f257c7cfe44014742ae46134047f49 (patch)
treed3465549106d04472cb05f70b317f20dd7fc77f6 /Objects/object.c
parentba6d5d1defd7a281c8c8804e4b4cfd7370886236 (diff)
downloadcpython-8728018624f257c7cfe44014742ae46134047f49.zip
cpython-8728018624f257c7cfe44014742ae46134047f49.tar.gz
cpython-8728018624f257c7cfe44014742ae46134047f49.tar.bz2
bpo-30860: Fix a refleak. (#3506)
* Drop warnoptions from PyInterpreterState. * Drop xoptions from PyInterpreterState. * Don't set warnoptions and _xoptions again. * Decref after adding to sys.__dict__. * Drop an unused macro. * Check sys.xoptions *before* we delete it.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 74893e3..ed8a62a 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -29,20 +29,23 @@ _Py_GetRefTotal(void)
return total;
}
-void
-_PyDebug_PrintTotalRefs(void) {
- PyObject *xoptions, *value;
+PyObject *
+_PyDebug_XOptionShowRefCount(void)
+{
+ PyObject *xoptions = PySys_GetXOptions();
+ if (xoptions == NULL)
+ return NULL;
+
_Py_IDENTIFIER(showrefcount);
+ return _PyDict_GetItemId(xoptions, &PyId_showrefcount);
+}
- xoptions = PySys_GetXOptions();
- if (xoptions == NULL)
- return;
- value = _PyDict_GetItemId(xoptions, &PyId_showrefcount);
- if (value == Py_True)
- fprintf(stderr,
- "[%" PY_FORMAT_SIZE_T "d refs, "
- "%" PY_FORMAT_SIZE_T "d blocks]\n",
- _Py_GetRefTotal(), _Py_GetAllocatedBlocks());
+void
+_PyDebug_PrintTotalRefs(void) {
+ fprintf(stderr,
+ "[%" PY_FORMAT_SIZE_T "d refs, "
+ "%" PY_FORMAT_SIZE_T "d blocks]\n",
+ _Py_GetRefTotal(), _Py_GetAllocatedBlocks());
}
#endif /* Py_REF_DEBUG */