bpo-36958: In IDLE, print exit message (GH-13435) · python/cpython@6d965b3

5 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -700,6 +700,9 @@ If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``,

700700

IDLE's changes are lost and input from the keyboard and output to the screen

701701

will not work correctly.

702702
703+

When user code raises SystemExit either directly or by calling sys.exit, IDLE

704+

returns to a Shell prompt instead of exiting.

705+
703706

User output in Shell

704707

^^^^^^^^^^^^^^^^^^^^

705708
Original file line numberDiff line numberDiff line change

@@ -3,6 +3,12 @@ Released on 2019-10-20?

33

======================================

44
55
6+

bpo-36958: Print any argument other than None or int passed to

7+

SystemExit or sys.exit().

8+
9+

bpo-36807: When saving a file, call file.flush() and os.fsync()

10+

so bits are flushed to e.g. a USB drive.

11+
612

bpo-36429: Fix starting IDLE with pyshell.

713

Add idlelib.pyshell alias at top; remove pyshell alias at bottom.

814

Remove obsolete __name__=='__main__' command.

Original file line numberDiff line numberDiff line change

@@ -659,6 +659,8 @@ <h3>Running user code<a class="headerlink" href="#running-user-code" title="Perm

659659

<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>,

660660

IDLE’s changes are lost and input from the keyboard and output to the screen

661661

will not work correctly.</p>

662+

<p>When user code raises SystemExit either directly or by calling sys.exit, IDLE

663+

returns to a Shell prompt instead of exiting.</p>

662664

</div>

663665

<div class="section" id="user-output-in-shell">

664666

<h3>User output in Shell<a class="headerlink" href="#user-output-in-shell" title="Permalink to this headline"></a></h3>

@@ -941,7 +943,7 @@ <h3>Navigation</h3>

941943

<br />

942944

<br />

943945
944-

Last updated on May 16, 2019.

946+

Last updated on May 19, 2019.

945947

<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?

946948

<br />

947949
Original file line numberDiff line numberDiff line change

@@ -474,15 +474,16 @@ def runcode(self, code):

474474

exec(code, self.locals)

475475

finally:

476476

interruptable = False

477-

except SystemExit:

478-

# Scripts that raise SystemExit should just

479-

# return to the interactive prompt

480-

pass

477+

except SystemExit as e:

478+

if e.args: # SystemExit called with an argument.

479+

ob = e.args[0]

480+

if not isinstance(ob, (type(None), int)):

481+

print('SystemExit: ' + str(ob), file=sys.stderr)

482+

# Return to the interactive prompt.

481483

except:

482484

self.usr_exc_info = sys.exc_info()

483485

if quitting:

484486

exit()

485-

# even print a user code SystemExit exception, continue

486487

print_exception()

487488

jit = self.rpchandler.console.getvar("<<toggle-jit-stack-viewer>>")

488489

if jit:

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,2 @@

1+

Print any argument other than None or int passed to SystemExit or

2+

sys.exit().