From 6d965b39b7a486dd9e96a60b19ee92382d668299 Mon Sep 17 00:00:00 2001
From: Terry Jan Reedy
Date: Sun, 19 May 2019 22:52:22 -0400
Subject: bpo-36958: In IDLE, print exit message (GH-13435)
Print any argument other than None or int passed to SystemExit
or sys.exit().
---
Doc/library/idle.rst | 3 +++
Lib/idlelib/NEWS.txt | 6 ++++++
Lib/idlelib/help.html | 4 +++-
Lib/idlelib/run.py | 11 ++++++-----
.../NEWS.d/next/IDLE/2019-05-19-22-02-22.bpo-36958.DZUC6G.rst | 2 ++
5 files changed, 20 insertions(+), 6 deletions(-)
create mode 100644 Misc/NEWS.d/next/IDLE/2019-05-19-22-02-22.bpo-36958.DZUC6G.rst
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index f511d64..c51cf19 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -700,6 +700,9 @@ If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``,
IDLE's changes are lost and input from the keyboard and output to the screen
will not work correctly.
+When user code raises SystemExit either directly or by calling sys.exit, IDLE
+returns to a Shell prompt instead of exiting.
+
User output in Shell
^^^^^^^^^^^^^^^^^^^^
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index be855bc..3f19ce7 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,6 +3,12 @@ Released on 2019-10-20?
======================================
+bpo-36958: Print any argument other than None or int passed to
+SystemExit or sys.exit().
+
+bpo-36807: When saving a file, call file.flush() and os.fsync()
+so bits are flushed to e.g. a USB drive.
+
bpo-36429: Fix starting IDLE with pyshell.
Add idlelib.pyshell alias at top; remove pyshell alias at bottom.
Remove obsolete __name__=='__main__' command.
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 56f9ca5..bc287d6 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -659,6 +659,8 @@ will then be attached to that window for input and output.
If sys
is reset by user code, such as with importlib.reload(sys)
,
IDLE’s changes are lost and input from the keyboard and output to the screen
will not work correctly.
+When user code raises SystemExit either directly or by calling sys.exit, IDLE
+returns to a Shell prompt instead of exiting.
User output in Shell
@@ -941,7 +943,7 @@ also used for testing.
- Last updated on May 16, 2019.
+ Last updated on May 19, 2019.
Found a bug?
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 6fa373f..b4a2b54 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -474,15 +474,16 @@ class Executive(object):
exec(code, self.locals)
finally:
interruptable = False
- except SystemExit:
- # Scripts that raise SystemExit should just
- # return to the interactive prompt
- pass
+ except SystemExit as e:
+ if e.args: # SystemExit called with an argument.
+ ob = e.args[0]
+ if not isinstance(ob, (type(None), int)):
+ print('SystemExit: ' + str(ob), file=sys.stderr)
+ # Return to the interactive prompt.
except:
self.usr_exc_info = sys.exc_info()
if quitting:
exit()
- # even print a user code SystemExit exception, continue
print_exception()
jit = self.rpchandler.console.getvar("<
>")
if jit:
diff --git a/Misc/NEWS.d/next/IDLE/2019-05-19-22-02-22.bpo-36958.DZUC6G.rst b/Misc/NEWS.d/next/IDLE/2019-05-19-22-02-22.bpo-36958.DZUC6G.rst
new file mode 100644
index 0000000..c5a675d
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2019-05-19-22-02-22.bpo-36958.DZUC6G.rst
@@ -0,0 +1,2 @@
+Print any argument other than None or int passed to SystemExit or
+sys.exit().
--
cgit v0.12