Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/library/idle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^^^^^^

Expand Down
6 changes: 6 additions & 0 deletions Lib/idlelib/NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion Lib/idlelib/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,8 @@ <h3>Running user code<a class="headerlink" href="#running-user-code" title="Perm
<p>If <code class="docutils literal notranslate"><span class="pre">sys</span></code> is reset by user code, such as with <code class="docutils literal notranslate"><span class="pre">importlib.reload(sys)</span></code>,
IDLE’s changes are lost and input from the keyboard and output to the screen
will not work correctly.</p>
<p>When user code raises SystemExit either directly or by calling sys.exit, IDLE
returns to a Shell prompt instead of exiting.</p>
</div>
<div class="section" id="user-output-in-shell">
<h3>User output in Shell<a class="headerlink" href="#user-output-in-shell" title="Permalink to this headline">¶</a></h3>
Expand Down Expand Up @@ -941,7 +943,7 @@ <h3>Navigation</h3>
<br />
<br />

Last updated on May 16, 2019.
Last updated on May 19, 2019.
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
<br />

Expand Down
11 changes: 6 additions & 5 deletions Lib/idlelib/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,16 @@ def runcode(self, code):
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("<<toggle-jit-stack-viewer>>")
if jit:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Print any argument other than None or int passed to SystemExit or
sys.exit().