8000 fix: Delay REPL check · etherscan-io/sentry-python@b9c98ef · GitHub
[go: up one dir, main page]

Skip to content

Commit b9c98ef

Browse files
committed
fix: Delay REPL check
Fix getsentry#122
1 parent bbeaf8f commit b9c98ef

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

sentry_sdk/integrations/excepthook.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2116
def _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

Comments
 (0)
0