[Python-checkins] cpython: fix refcnt/style/debuging oversights

benjamin.peterson python-checkins at python.org
Wed Apr 18 16:48:07 CEST 2012


http://hg.python.org/cpython/rev/e8c87226bcb3
changeset:   76389:e8c87226bcb3
user:        Benjamin Peterson <benjamin at python.org>
date:        Wed Apr 18 10:48:00 2012 -0400
summary:
  fix refcnt/style/debuging oversights

files:
  Python/errors.c |  12 +++++++-----
  1 files changed, 7 insertions(+), 5 deletions(-)


diff --git a/Python/errors.c b/Python/errors.c
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -593,13 +593,15 @@
     if (msg == NULL)
         return NULL;
 
-    args = PyTuple_New(1);
+    args = PyTuple_New(0);
     if (args == NULL)
         return NULL;
 
     kwargs = PyDict_New();
-    if (kwargs == NULL)
+    if (kwargs == NULL) {
+        Py_DECREF(args);
         return NULL;
+    }
 
     if (name == NULL) {
         Py_INCREF(Py_None);
@@ -612,13 +614,13 @@
     }
 
     Py_INCREF(msg);
-    PyTuple_SetItem(args, 0, NULL);//msg);
+    PyTuple_SET_ITEM(args, 0, msg);
     PyDict_SetItemString(kwargs, "name", name);
     PyDict_SetItemString(kwargs, "path", path);
 
     error = PyObject_Call(PyExc_ImportError, args, kwargs);
-    if (error!= NULL) {
-        PyErr_SetObject((PyObject *) Py_TYPE(error), error);
+    if (error != NULL) {
+        PyErr_SetObject((PyObject *)Py_TYPE(error), error);
         Py_DECREF(error);
     }
 

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


More information about the Python-checkins mailing list