mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
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.
This commit is contained in:
parent
ba6d5d1def
commit
8728018624
7 changed files with 47 additions and 43 deletions
|
@ -29,20 +29,23 @@ _Py_GetRefTotal(void)
|
|||
return total;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
_PyDebug_XOptionShowRefCount(void)
|
||||
{
|
||||
PyObject *xoptions = PySys_GetXOptions();
|
||||
if (xoptions == NULL)
|
||||
return NULL;
|
||||
|
||||
_Py_IDENTIFIER(showrefcount);
|
||||
return _PyDict_GetItemId(xoptions, &PyId_showrefcount);
|
||||
}
|
||||
|
||||
void
|
||||
_PyDebug_PrintTotalRefs(void) {
|
||||
PyObject *xoptions, *value;
|
||||
_Py_IDENTIFIER(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());
|
||||
fprintf(stderr,
|
||||
"[%" PY_FORMAT_SIZE_T "d refs, "
|
||||
"%" PY_FORMAT_SIZE_T "d blocks]\n",
|
||||
_Py_GetRefTotal(), _Py_GetAllocatedBlocks());
|
||||
}
|
||||
#endif /* Py_REF_DEBUG */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue