diff Python/errors.c @ 76388:bf23a6c215f6

Fix email post-commit review comments. Add INCREFs, fix args->kwargs, and a second args==NULL check was removed, left over from a merger with another function. Instead, checking msg==NULL does what that used to do in a roundabout way.
author Brian Curtin <brian@python.org>
date Wed, 18 Apr 2012 08:30:51 -0500
parents 7a32b9380ffd
children e8c87226bcb3
line wrap: on
line diff
--- a/Python/errors.c	Tue Apr 17 21:42:07 2012 -0400
+++ b/Python/errors.c	Wed Apr 18 08:30:51 2012 -0500
@@ -590,29 +590,32 @@
 {
     PyObject *args, *kwargs, *error;
 
+    if (msg == NULL)
+        return NULL;
+
     args = PyTuple_New(1);
     if (args == NULL)
         return NULL;
 
     kwargs = PyDict_New();
-    if (args == NULL)
+    if (kwargs == NULL)
         return NULL;
 
-    if (name == NULL)
+    if (name == NULL) {
+        Py_INCREF(Py_None);
         name = Py_None;
+    }
 
-    if (path == NULL)
+    if (path == NULL) {
+        Py_INCREF(Py_None);
         path = Py_None;
+    }
 
     Py_INCREF(msg);
-    PyTuple_SetItem(args, 0, msg);
+    PyTuple_SetItem(args, 0, NULL);//msg);
     PyDict_SetItemString(kwargs, "name", name);
     PyDict_SetItemString(kwargs, "path", path);
 
-    /* args must at least be an empty tuple */
-    if (args == NULL)
-        args = PyTuple_New(0);
-
     error = PyObject_Call(PyExc_ImportError, args, kwargs);
     if (error!= NULL) {
         PyErr_SetObject((PyObject *) Py_TYPE(error), error);