You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError when except* catches an unhashable exception #99181
I recently had pytest-dev/pytest#10466 reported, and it seems likely to be an upstream bug in except* - cc @iritkatriel fyi.
A somewhat simplified reproducing example:
classMyException(Exception):
__hash__=None# Traditional try-except works fine with unhashable exceptions, e.g.:try:
raiseExceptionGroup("Foo", [MyException("Bar")])
exceptException:
pass# But here we'll get a TypeError:try:
raiseExceptionGroup("Foo", [MyException("Bar")])
except* Exception:
pass
+ Exception Group Traceback (most recent call last):
| File "repro.py", line 12, in <module>
| raise ExceptionGroup("Foo", [MyException("Bar")])
| ExceptionGroup: Foo (1 sub-exception)
+-+---------------- 1 ----------------
| MyException: Bar
+------------------------------------
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "repro.py", line -1, in <module>
TypeError: unhashable type: 'MyException'
If this is the intended behavior of course we'll work around it in Pytest, but we decided to report upstream in case it's not 🙂
Activity
iritkatriel commentedon Nov 7, 2022
Yes it’s a bug. Thanks.
pythongh-99181: fix except* on unhashable exceptions
pythongh-99181: fix except* on unhashable exceptions
pythongh-99181: fix except* on unhashable exceptions
gh-99181: fix except* on unhashable exceptions (GH-99192)
pythongh-99181: fix except* on unhashable exceptions (pythonGH-99192)
gh-99181: fix except* on unhashable exceptions (GH-99192)