]> granicus.if.org Git - python/commitdiff
Fix refleaks in test_capi
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 18 Jan 2012 20:23:13 +0000 (21:23 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 18 Jan 2012 20:23:13 +0000 (21:23 +0100)
(this was easier than I thought!)

Objects/exceptions.c

index fc41853d265746bf0d03730853dda6565796b50e..e5505917872ae5d6ee3d93aa4515af3154b04761 100644 (file)
@@ -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.");