diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-18 20:24:18 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-18 20:24:18 (GMT) |
commit | 84091bfa4509e61f2115addbcbdd3f5dd95c1964 (patch) | |
tree | 681e3b11f4714be5c42e446610aa36896cdfe48e /Objects/exceptions.c | |
parent | 165e01f83f64061fc66440e2e13b095d4ce9c755 (diff) | |
parent | 55f217f22d41630543d64def03324b2eeaedbd8d (diff) | |
download | cpython-84091bfa4509e61f2115addbcbdd3f5dd95c1964.zip cpython-84091bfa4509e61f2115addbcbdd3f5dd95c1964.tar.gz cpython-84091bfa4509e61f2115addbcbdd3f5dd95c1964.tar.bz2 |
Fix some of the refleaks in test_capi (ported from 3.2)
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 2eb1aab..ab71605 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -2213,10 +2213,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."); |