summaryrefslogtreecommitdiffstats
path: root/Objects/exceptions.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-18 20:24:18 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-18 20:24:18 (GMT)
commit84091bfa4509e61f2115addbcbdd3f5dd95c1964 (patch)
tree681e3b11f4714be5c42e446610aa36896cdfe48e /Objects/exceptions.c
parent165e01f83f64061fc66440e2e13b095d4ce9c755 (diff)
parent55f217f22d41630543d64def03324b2eeaedbd8d (diff)
downloadcpython-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.c10
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.");