QUERY · ISSUE
Exception.__init__ raises TypeError if overridden and called by subclass
bugpy-core
>>> class A(Exception):
... def __init__(self):
... Exception.__init__(self)
...
>>> a = A()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in __init__
TypeError: argument should be a 'Exception' not a 'A'
Why is Exception being enforced here, even if A is a subclass of Exception? That makes it hard to subclass from Exception and override __init__.
CANDIDATE · ISSUE
Exception chaining not implemented
This is mostly for tracking differences from CPython.
Also, can discuss if we need this.
Doc: http://legacy.python.org/dev/peps/pep-3134/
Roughly, raising a new exception (not reraising) when we handle another exception, chains them. But CPython prints them not like Java, but upside down:
Traceback (most recent call last):
File "try-reraise3.py", line 5, in <module>
raise ValueError
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "try-reraise3.py", line 7, in <module>
raise TypeError
TypeError
(But I guess Python prints traceback in reverse order comparing to java either, so the above behavior would be "natural" (the "most important" info printed last)).