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
It looks like even on Python 3.11.5, the ExceptionGroup shim is being used, see for instance:
❯ python3.11 -c "import packaging.metadata; print(packaging.metadata.ExceptionGroup.__doc__); print(packaging.metadata.ExceptionGroup); print(__builtins__.ExceptionGroup)"
A minimal implementation of :external:exc:`ExceptionGroup` from Python 3.11.
If :external:exc:`ExceptionGroup` is already defined by Python itself,
that version is used instead.
<class 'packaging.metadata.ExceptionGroup'>
<class 'ExceptionGroup'>
This is causing errors not to function correctly with except*.
The text was updated successfully, but these errors were encountered:
Not going to lie, I don't really understand what's happening here.
If I edit packaging/metadata.py and drop a print(type(__builtins__)) it tells me that the type is a dict, but if I do python3.11 -c "print(type(__builtins__))" it tells me the type is a module.
If I change the shim to get activated using:
try:
ExceptionGroup=ExceptionGroupexceptNameError:
classExceptionGroup(Exception): # type: ignore[no-redef] # noqa: N818"""A minimal implementation of :external:exc:`ExceptionGroup` from Python 3.11. If :external:exc:`ExceptionGroup` is already defined by Python itself, that version is used instead. """message: strexceptions: List[Exception]
def__init__(self, message: str, exceptions: List[Exception]) ->None:
self.message=messageself.exceptions=exceptionsdef__repr__(self) ->str:
returnf"{self.__class__.__name__}({self.message!r}, {self.exceptions!r})"
I think the following would be clearer (separating the name lookup vs reassignment as a global) and I'm onboard for moving to a try-except regardless of the specific form.
try:
ExceptionGroup
except NameError:
...
else:
ExceptionGroup = ExceptionGroup # all the linter ignores
It looks like even on Python 3.11.5, the
ExceptionGroup
shim is being used, see for instance:This is causing errors not to function correctly with
except*
.The text was updated successfully, but these errors were encountered: