[Python-checkins] cpython: Finally fix all test_capi refleaks

antoine.pitrou python-checkins at python.org
Wed Jan 18 21:49:03 CET 2012


http://hg.python.org/cpython/rev/c19b0ae5cd91
changeset:   74510:c19b0ae5cd91
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Wed Jan 18 21:45:15 2012 +0100
summary:
  Finally fix all test_capi refleaks

files:
  Python/_warnings.c |  25 ++++++++++++++++---------
  1 files changed, 16 insertions(+), 9 deletions(-)


diff --git a/Python/_warnings.c b/Python/_warnings.c
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -958,23 +958,30 @@
     if (m == NULL)
         return NULL;
 
-    _filters = init_filters();
-    if (_filters == NULL)
-        return NULL;
+    if (_filters == NULL) {
+        _filters = init_filters();
+        if (_filters == NULL)
+            return NULL;
+    }
     Py_INCREF(_filters);
     if (PyModule_AddObject(m, "filters", _filters) < 0)
         return NULL;
 
-    _once_registry = PyDict_New();
-    if (_once_registry == NULL)
-        return NULL;
+    if (_once_registry == NULL) {
+        _once_registry = PyDict_New();
+        if (_once_registry == NULL)
+            return NULL;
+    }
     Py_INCREF(_once_registry);
     if (PyModule_AddObject(m, "_onceregistry", _once_registry) < 0)
         return NULL;
 
-    _default_action = PyUnicode_FromString("default");
-    if (_default_action == NULL)
-        return NULL;
+    if (_default_action == NULL) {
+        _default_action = PyUnicode_FromString("default");
+        if (_default_action == NULL)
+            return NULL;
+    }
+    Py_INCREF(_default_action);
     if (PyModule_AddObject(m, "_defaultaction", _default_action) < 0)
         return NULL;
     return m;

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


More information about the Python-checkins mailing list