[issue12029] Catching virtual subclasses in except clauses

Georg Brandl report at bugs.python.org
Thu Oct 2 12:01:50 CEST 2014


Georg Brandl added the comment:

I'm attaching a patch that works without changing the recursion limit, and adds some tests for pathological cases.

Instead, PyErr_GivenExceptionMatches is changed so that if an exception was previously set, it is replaced by an exception that PyObject_IsSubclass raises.  In that way recursion errors should be propagated properly.

In exception matching, this means that exceptions (including recursion errors) from PyObject_IsSubclass are ignored.  There is already an explicit test for this behavior in test_exceptions.

This behavior *could* be changed if intended by introducing a variant of PyErr_GivenExceptionMatches that can set an exception even if none was set before, and calling that in cmp_outcome in ceval.

----------
nosy: +georg.brandl
Added file: http://bugs.python.org/file36776/exception_proper_subclass_matching.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12029>
_______________________________________


More information about the Python-bugs-list mailing list