@@ -10,19 +10,15 @@ class ExcepthookIntegration(Integration):
10
10
11
11
@staticmethod
12
12
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
-
18
13
sys .excepthook = _make_excepthook (sys .excepthook )
19
14
20
15
21
16
def _make_excepthook (old_excepthook ):
22
17
def sentry_sdk_excepthook (exctype , value , traceback ):
23
18
hub = Hub .current
24
19
integration = hub .get_integration (ExcepthookIntegration )
25
- if integration is not None :
20
+
21
+ if integration is not None and _should_send ():
26
22
with capture_internal_exceptions ():
27
23
event , hint = event_from_exception (
28
24
(exctype , value , traceback ),
@@ -34,3 +30,12 @@ def sentry_sdk_excepthook(exctype, value, traceback):
34
30
return old_excepthook (exctype , value , traceback )
35
31
36
32
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