summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-18 20:23:13 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-18 20:23:13 (GMT)
commit55f217f22d41630543d64def03324b2eeaedbd8d (patch)
treede5137431217ed8bace5b45576032b85ce303079 /Objects
parent6c40eb7f421804eba3c24a9336c4a9e59dba636c (diff)
downloadcpython-55f217f22d41630543d64def03324b2eeaedbd8d.zip
cpython-55f217f22d41630543d64def03324b2eeaedbd8d.tar.gz
cpython-55f217f22d41630543d64def03324b2eeaedbd8d.tar.bz2
Fix refleaks in test_capi
(this was easier than I thought!)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index fc41853..e550591 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.");