mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Check the return code for PyErr_Warn() when warning about raising string
exceptions. This was triggered when 'warnings' had a filter set to "error" that caught the string exception deprecation warning.
This commit is contained in:
parent
a7444f47b2
commit
a7446e3438
2 changed files with 9 additions and 4 deletions
|
@ -2997,13 +2997,14 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
|
|||
Py_DECREF(tmp);
|
||||
}
|
||||
|
||||
if (PyString_CheckExact(type))
|
||||
if (PyString_CheckExact(type)) {
|
||||
/* Raising builtin string is deprecated but still allowed --
|
||||
* do nothing. Raising an instance of a new-style str
|
||||
* subclass is right out. */
|
||||
PyErr_Warn(PyExc_PendingDeprecationWarning,
|
||||
"raising a string exception is deprecated");
|
||||
|
||||
if (-1 == PyErr_Warn(PyExc_PendingDeprecationWarning,
|
||||
"raising a string exception is deprecated"))
|
||||
goto raise_error;
|
||||
}
|
||||
else if (PyClass_Check(type))
|
||||
PyErr_NormalizeException(&type, &value, &tb);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue