Skip to content

Commit 55f217f

Browse files
committed
Fix refleaks in test_capi
(this was easier than I thought!)
1 parent 6c40eb7 commit 55f217f

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Objects/exceptions.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,10 +1959,14 @@ SimpleExtendsException(PyExc_Warning, ResourceWarning,
19591959
*/
19601960
PyObject *PyExc_RecursionErrorInst = NULL;
19611961

1962-
#define PRE_INIT(TYPE) if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \
1963-
Py_FatalError("exceptions bootstrapping error.");
1962+
#define PRE_INIT(TYPE) \
1963+
if (!(_PyExc_ ## TYPE.tp_flags & Py_TPFLAGS_READY)) { \
1964+
if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \
1965+
Py_FatalError("exceptions bootstrapping error."); \
1966+
Py_INCREF(PyExc_ ## TYPE); \
1967+
}
19641968

1965-
#define POST_INIT(TYPE) Py_INCREF(PyExc_ ## TYPE); \
1969+
#define POST_INIT(TYPE) \
19661970
if (PyDict_SetItemString(bdict, # TYPE, PyExc_ ## TYPE)) \
19671971
Py_FatalError("Module dictionary insertion problem.");
19681972

0 commit comments

Comments
 (0)