mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Don't decref exc too soon
This commit is contained in:
parent
c4c2580d43
commit
4b9b936429
1 changed files with 2 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue