mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #18408: Fix PyErr_NormalizeException(), handle PyObject_IsSubclass() failure
PyObject_IsSubclass() can fail and raise a new exception!
This commit is contained in:
parent
bdf630c4a7
commit
74a7fa6663
1 changed files with 10 additions and 1 deletions
|
@ -227,12 +227,21 @@ PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
|
||||||
value will be an instance.
|
value will be an instance.
|
||||||
*/
|
*/
|
||||||
if (PyExceptionClass_Check(type)) {
|
if (PyExceptionClass_Check(type)) {
|
||||||
|
int is_subclass;
|
||||||
|
if (inclass) {
|
||||||
|
is_subclass = PyObject_IsSubclass(inclass, type);
|
||||||
|
if (is_subclass < 0)
|
||||||
|
goto finally;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
is_subclass = 0;
|
||||||
|
|
||||||
/* if the value was not an instance, or is not an instance
|
/* if the value was not an instance, or is not an instance
|
||||||
whose class is (or is derived from) type, then use the
|
whose class is (or is derived from) type, then use the
|
||||||
value as an argument to instantiation of the type
|
value as an argument to instantiation of the type
|
||||||
class.
|
class.
|
||||||
*/
|
*/
|
||||||
if (!inclass || !PyObject_IsSubclass(inclass, type)) {
|
if (!inclass || !is_subclass) {
|
||||||
PyObject *args, *res;
|
PyObject *args, *res;
|
||||||
|
|
||||||
if (value == Py_None)
|
if (value == Py_None)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue