From: Antoine Pitrou Date: Wed, 18 Jan 2012 20:23:13 +0000 (+0100) Subject: Fix refleaks in test_capi X-Git-Tag: v3.2.3rc1~155 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=55f217f22d41630543d64def03324b2eeaedbd8d;p=thirdparty%2FPython%2Fcpython.git Fix refleaks in test_capi (this was easier than I thought!) --- diff --git a/Objects/exceptions.c b/Objects/exceptions.c index fc41853d2657..e5505917872a 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -1959,10 +1959,14 @@ SimpleExtendsException(PyExc_Warning, ResourceWarning, */ PyObject *PyExc_RecursionErrorInst = NULL; -#define PRE_INIT(TYPE) if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \ - Py_FatalError("exceptions bootstrapping error."); +#define PRE_INIT(TYPE) \ + if (!(_PyExc_ ## TYPE.tp_flags & Py_TPFLAGS_READY)) { \ + if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \ + Py_FatalError("exceptions bootstrapping error."); \ + Py_INCREF(PyExc_ ## TYPE); \ + } -#define POST_INIT(TYPE) Py_INCREF(PyExc_ ## TYPE); \ +#define POST_INIT(TYPE) \ if (PyDict_SetItemString(bdict, # TYPE, PyExc_ ## TYPE)) \ Py_FatalError("Module dictionary insertion problem.");