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
sentry_sdk.init breaks import exceptiongroup in virtualenv activated with activate_this.py #3097
Traceback (most recent call last):
File "//test.py", line 4, in <module>import exceptiongroup
File "/venv/lib/python3.10/site-packages/exceptiongroup/__init__.py", line 20, in <module>from ._formatting import (
File "/venv/lib/python3.10/site-packages/exceptiongroup/_formatting.py", line 394, in <module>assert sys.excepthook is apport_python_hook.apport_excepthook
AssertionError
Sentry is attempting to send 2 pending events
Waiting up to 2 seconds
Press Ctrl-C to quit
ifgetattr(sys.excepthook, "__name__", None) in (
"apport_excepthook",
# on ubuntu 22.10 the hook was renamed to partial_apport_excepthook"partial_apport_excepthook",
):
…
importapport_python_hookassertsys.excepthookisapport_python_hook.apport_excepthook
which fails because Sentry has patched sys.excepthook but retained the same __name__, due to functools.wraps within the ensure_integration_enabled decorator, used by _make_excepthook as of
This is arguably poor code within exceptiongroup (I opened agronholm/exceptiongroup#123), but Sentry should avoid breaking it since it’s a popular library; for example, it’s a dependency of IPython.
Activity
antonpirker commentedon May 23, 2024
Hey @andersk
Thanks for reporting this and for the great reproduction!
Because of the great reproduction, it was easy to come of with a fix!
antonpirker commentedon May 23, 2024
Released a fix for this in
2.3.1: https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md