[Python-checkins] cpython (merge 3.2 -> default): Fix some of the refleaks in test_capi (ported from 3.2)

antoine.pitrou python-checkins at python.org
Wed Jan 18 21:29:35 CET 2012


http://hg.python.org/cpython/rev/0db59d274d68
changeset:   74507:0db59d274d68
parent:      74505:3fee4f07aeab
parent:      74506:5ffa409af22e
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Wed Jan 18 21:24:18 2012 +0100
summary:
  Fix some of the refleaks in test_capi (ported from 3.2)

files:
  Objects/exceptions.c |  10 +++++++---
  1 files changed, 7 insertions(+), 3 deletions(-)


diff --git a/Objects/exceptions.c b/Objects/exceptions.c
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -2213,10 +2213,14 @@
 */
 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.");
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list