Skip to content

Commit 51e8cef

Browse files
kdartthomasballinger
authored andcommitted
Make the debugger selection issue a warning if it could not be loaded.
1 parent d274eba commit 51e8cef

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

bpython/cli.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@
8181
from bpython import translations
8282
from bpython.translations import _
8383

84+
# Debugging support
85+
try:
86+
from bpython import debugger
87+
except ImportError as err:
88+
debugger = None
89+
8490
from bpython import repl
8591
from bpython._py3compat import py3
8692
from bpython.pager import page
@@ -959,6 +965,11 @@ def p_key(self, key):
959965
return ''
960966

961967
elif key in key_dispatch[config.debug_key]:
968+
if debugger is None:
969+
self.echo(
970+
"\x01y\x03No debugger, check your PYTHON_DEBUGGER value.\n",
971+
)
972+
return
962973
if sys.excepthook is not debugger_hook:
963974
sys.excepthook = debugger_hook
964975
else:
@@ -1960,7 +1971,6 @@ def debugger_hook(exc, value, tb):
19601971
return
19611972

19621973
global stdscr
1963-
from bpython import debugger
19641974

19651975
orig_stdin = sys.stdin
19661976
orig_stdout = sys.stdout
@@ -1997,7 +2007,7 @@ def main(args=None, locals_=None, banner=None):
19972007
orig_stdout = sys.stdout
19982008
orig_stderr = sys.stderr
19992009

2000-
if options.debugger:
2010+
if options.debugger and debugger is not None:
20012011
sys.excepthook = debugger_hook
20022012

20032013
try:

0 commit comments

Comments
 (0)