diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2013-11-15 14:34:13 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2013-11-15 14:34:13 (GMT) |
commit | 4b9b936429c8d013b0e954d0a4d30832e6354439 (patch) | |
tree | f12881f71ad6b8c4fca58aa2a96cd4feaf685d6e /Objects/exceptions.c | |
parent | c4c2580d43880ac2013aff5e72674bae379c99a4 (diff) | |
download | cpython-4b9b936429c8d013b0e954d0a4d30832e6354439.zip cpython-4b9b936429c8d013b0e954d0a4d30832e6354439.tar.gz cpython-4b9b936429c8d013b0e954d0a4d30832e6354439.tar.bz2 |
Don't decref exc too soon
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index bb61ea5..3476db0 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -2685,7 +2685,6 @@ _PyErr_TrySetFromCause(const char *format, ...) * state potentially stored on OSError instances. */ - Py_DECREF(exc); Py_XDECREF(tb); #ifdef HAVE_STDARG_PROTOTYPES @@ -2696,12 +2695,14 @@ _PyErr_TrySetFromCause(const char *format, ...) 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); |