[Python-checkins] cpython: Don't decref exc too soon

nick.coghlan python-checkins at python.org
Fri Nov 15 15:34:25 CET 2013


http://hg.python.org/cpython/rev/ace11097a22e
changeset:   87110:ace11097a22e
user:        Nick Coghlan <ncoghlan at gmail.com>
date:        Sat Nov 16 00:34:13 2013 +1000
summary:
  Don't decref exc too soon

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


diff --git a/Objects/exceptions.c b/Objects/exceptions.c
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -2685,7 +2685,6 @@
      * state potentially stored on OSError instances.
      */
 
-    Py_DECREF(exc);
     Py_XDECREF(tb);
 
 #ifdef HAVE_STDARG_PROTOTYPES
@@ -2696,12 +2695,14 @@
     msg_prefix = PyUnicode_FromFormatV(format, vargs);
     va_end(vargs);
     if (msg_prefix == NULL) {
+        Py_DECREF(exc);
         Py_DECREF(val);
         return NULL;
     }
 
     PyErr_Format(exc, "%U (%s: %S)",
                  msg_prefix, Py_TYPE(val)->tp_name, val);
+    Py_DECREF(exc);
     Py_DECREF(msg_prefix);
     PyErr_Fetch(&new_exc, &new_val, &new_tb);
     PyErr_NormalizeException(&new_exc, &new_val, &new_tb);

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


More information about the Python-checkins mailing list