@@ -10,19 +10,15 @@ class ExcepthookIntegration(Integration):
1010
1111 @staticmethod
1212 def setup_once ():
13- if hasattr (sys , "ps1" ):
14- # Disable the excepthook for interactive Python shells, otherwise
15- # every typo gets sent to Sentry.
16- return
17-
1813 sys .excepthook = _make_excepthook (sys .excepthook )
1914
2015
2116def _make_excepthook (old_excepthook ):
2217 def sentry_sdk_excepthook (exctype , value , traceback ):
2318 hub = Hub .current
2419 integration = hub .get_integration (ExcepthookIntegration )
25- if integration is not None :
20+
21+ if integration is not None and _should_send ():
2622 with capture_internal_exceptions ():
2723 event , hint = event_from_exception (
2824 (exctype , value , traceback ),
@@ -34,3 +30,12 @@ def sentry_sdk_excepthook(exctype, value, traceback):
3430 return old_excepthook (exctype , value , traceback )
3531
3632 return sentry_sdk_excepthook
33+
34+
35+ def _should_send ():
36+ if hasattr (sys , "ps1" ):
37+ # Disable the excepthook for interactive Python shells, otherwise
38+ # every typo gets sent to Sentry.
39+ return False
40+
41+ return True
0 commit comments