Closed sanderr closed 1 year ago
@cfbolz comments?
right, I see. yes, it should definitely not crash, sorry for not thinking about this case. I'm fixing it.
No problem, thanks for the quick resolution!
@sanderr are you able to test against main
? I will make a release then.
It works as expected:
tests/test_exceptiongroup.py F [100%]
========================================== FAILURES ===========================================
__________________________________ test_exceptiongroup_error __________________________________
def test_exceptiongroup_error() -> None:
> raise NamedAttributeError(name="mykey")
E test_exceptiongroup.NamedAttributeError
tests/test_exceptiongroup.py:10: NamedAttributeError
Released v1.0.4.
Thanks a lot! I really hadn't expected this to be resolved today.
Observed behavior
Running
pytest
on the snippet below results in an error while attempting to construct the traceback.Details
This behavior was introduced in 1.0.3. It seems to assume that if the
name
attribute is set, theobj
attribute will be set as well. As far as I understand there are two issues with that assumption:name
andobj
attributes are only introduced in Python 3.10. In Python 3.9 and below it is perfectly valid to introduce a custom subclass that happens to have one or both of these names, which might have different meanings entirely than the ones defined in 3.10+.The second issue could be argued to be of lesser importance (and more difficult to address). The first I would call a breaking bug.
Environment
I'm using the latest versions of
pytest-7.2.0
andexceptiongroup-1.0.3
at the time of writing, but I believe olderpytest
versions are also susceptible to this issue.