bpo-46857: Fix refleak in OSError INIT_ALIAS() (GH-31594)

_Py_GetRefTotal() no longer decrements _PySet_Dummy refcount.
This commit is contained in:
Victor Stinner 2022-02-27 00:28:24 +01:00 committed by GitHub
parent e182c660b6
commit ad56919c5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 18 deletions

View file

@ -15,10 +15,10 @@
/* Compatibility aliases */
PyObject *PyExc_EnvironmentError = NULL;
PyObject *PyExc_IOError = NULL;
PyObject *PyExc_EnvironmentError = NULL; // borrowed ref
PyObject *PyExc_IOError = NULL; // borrowed ref
#ifdef MS_WINDOWS
PyObject *PyExc_WindowsError = NULL;
PyObject *PyExc_WindowsError = NULL; // borrowed ref
#endif
@ -3647,10 +3647,8 @@ _PyBuiltins_AddExceptions(PyObject *bltinmod)
#define INIT_ALIAS(NAME, TYPE) \
do { \
Py_INCREF(PyExc_ ## TYPE); \
Py_XDECREF(PyExc_ ## NAME); \
PyExc_ ## NAME = PyExc_ ## TYPE; \
if (PyDict_SetItemString(mod_dict, # NAME, PyExc_ ## NAME)) { \
if (PyDict_SetItemString(mod_dict, # NAME, PyExc_ ## TYPE)) { \
return -1; \
} \
} while (0)