[issue11627] segfault raising an arbitrary object as an exception

Andreas Stührk report at bugs.python.org
Wed Mar 23 03:33:38 CET 2011

Andreas Stührk <andy-python at hammerhartes.de> added the comment:

Another thing that can happen is that `__new__()` does return an instance of BaseException, but that the return value is not an instance of the expected class.


class MyException(OSError):
    def __new__(*args):
        return Exception()

    raise MyException
except OSError as e:
    print(isinstance(e, OSError))

That would print "False". Currently, the patch doesn't check for that, should it do so?

Also, the error message for the 2.7 patch doesn't include that old-style classes are allowed, hence the patch needs to be updated if it should go into 2.7.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list