diff options
author | Victor Stinner <vstinner@python.org> | 2022-02-26 23:28:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-26 23:28:24 (GMT) |
commit | ad56919c5ed54523f866e6605a2573ab7b7d5235 (patch) | |
tree | 1cc23ffd1c3f58b123ff0936852a08bb86f32b88 /Objects/exceptions.c | |
parent | e182c660b63bc23420fb9f0593d77a3fa3b7f1c7 (diff) | |
download | cpython-ad56919c5ed54523f866e6605a2573ab7b7d5235.zip cpython-ad56919c5ed54523f866e6605a2573ab7b7d5235.tar.gz cpython-ad56919c5ed54523f866e6605a2573ab7b7d5235.tar.bz2 |
bpo-46857: Fix refleak in OSError INIT_ALIAS() (GH-31594)
_Py_GetRefTotal() no longer decrements _PySet_Dummy refcount.
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 977dce5..9dbbd40 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -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) |