Skip to content

Commit b484236

Browse files
committed
Fix return value of main_curses if we execute a file
1 parent 852825a commit b484236

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

bpython/cli.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,10 +1874,17 @@ def main_curses(scr, args, config, interactive=True, locals_=None,
18741874
sys.stderr = FakeStream(clirepl)
18751875

18761876
if args:
1877-
bpython.args.exec_code(interpreter, args)
1877+
exit_value = 0
1878+
try:
1879+
bpython.args.exec_code(interpreter, args)
1880+
except SystemExit, e:
1881+
# The documentation of code.InteractiveInterpreter.runcode claims
1882+
# that it reraises SystemExit. However, I can't manage to trigger
1883+
# that. To be one the safe side let's catch SystemExit here anyway.
1884+
exit_value = e.args
18781885
if not interactive:
18791886
curses.raw(False)
1880-
return clirepl.getstdout()
1887+
return (exit_value, clirepl.getstdout())
18811888
else:
18821889
sys.path.insert(0, '')
18831890
clirepl.startup()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy