classification
Title: code.interact() should print an exit message
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: steven.daprano Nosy List: arigo, brett.cannon, ned.deily, paul.moore, python-dev, steven.daprano
Priority: normal Keywords: patch

Created on 2016-07-19 12:55 by steven.daprano, last changed 2016-08-23 16:41 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
code.patch steven.daprano, 2016-07-19 13:36 review
Messages (12)
msg270822 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2016-07-19 12:55
Way too often I've lost track of whether I'm in the code.interact() REPL or the original REPL, or hit Ctrl-D once too often, and accidentally quit the real REPL. It is easy to lose track, since the real and imitation REPL both use the same prompts.

It would be useful if code.interact() and the InteractiveConsole printed a message when they exited.
msg270825 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2016-07-19 13:36
This time, with a patch that includes updated tests.
msg272678 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-08-14 16:10
LGTM
msg272680 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2016-08-14 16:28
LGTM. Maybe worth a documentation note - "Changed in 3.6 - added an exit message"? But I'm OK with it as is if you don't think that's worth it.
msg272684 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-08-14 18:17
New changeset 9410dc027505 by Steven D'Aprano in branch 'default':
Issue27573 code.interact prints a message when exiting.
https://hg.python.org/cpython/rev/9410dc027505
msg272687 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-08-14 18:46
Steven, don't forget to update Misc/NEWS and to close this issue on the bug tracker.  Thanks!
msg273016 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2016-08-18 08:19
Can we make the exit message optional?  Otherwise PyPy will need to patch code.py to add the option to not display this message when used as the normal REPL (yes, PyPy uses the plain code.py as its built-in REPL).
msg273019 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2016-08-18 10:59
On Thu, Aug 18, 2016 at 08:19:25AM +0000, Armin Rigo wrote:
> Can we make the exit message optional?

Sure. What API do you prefer? I'm thinking to just give interact() an 
optional "exitmsg" argument, similar to banner:

def interact(banner=None, readfunc=None, local=None, exitmsg=None):

and similar for InteractiveConsole.interact.

If you're happy with that, I should be able to get the change done over 
this coming weekend.
msg273021 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2016-08-18 12:13
I'm fine with `exitmsg`.  I guess it would be a flag (not `None` as you wrote), defaulting to `True`?
msg273022 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2016-08-18 12:26
...ah, upon closer inspection, we don't use the ``interact()`` method anyway.  We already copied and tweaked this method: one problem was that it gives no way to run without printing at least one '\n' of banner at the beginning.  Then a more important tweak was made when we added multiline input with `pyrepl` by default.  So feel free to ignore my request.

(Multiline input is great, btw, if you use the interactive Python a lot.  That would be a completely different patch---if I thought that there's a good chance of it not languishing forever on this bug tracker, which I honestly don't think is the case...)
msg273459 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2016-08-23 14:49
On Thu, Aug 18, 2016 at 12:26:56PM +0000, Armin Rigo wrote:
> ...ah, upon closer inspection, we don't use the ``interact()`` method 
> anyway.  We already copied and tweaked this method: one problem was 
> that it gives no way to run without printing at least one '\n' of 
> banner at the beginning.  Then a more important tweak was made when we 
> added multiline input with `pyrepl` by default.  So feel free to 
> ignore my request.

I think making the exit message configurable is a good idea even if PyPy 
doesn't do it, and it should be an easy few lines, so I'll do it even if 
you don't need it for PyPy.
msg273485 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-08-23 16:41
New changeset c4863530cfd6 by Steven D'Aprano in branch 'default':
Issue #27573 make the exit message configurable.
https://hg.python.org/cpython/rev/c4863530cfd6
History
Date User Action Args
2016-08-23 16:41:03python-devsetmessages: + msg273485
2016-08-23 14:49:59steven.dapranosetmessages: + msg273459
2016-08-18 12:26:56arigosetmessages: + msg273022
2016-08-18 12:13:56arigosetmessages: + msg273021
2016-08-18 10:59:12steven.dapranosetmessages: + msg273019
2016-08-18 08:19:25arigosetnosy: + arigo
messages: + msg273016
2016-08-15 01:20:09steven.dapranosetstatus: open -> closed
resolution: fixed
stage: resolved
2016-08-14 18:46:55ned.deilysetnosy: + ned.deily
messages: + msg272687
2016-08-14 18:17:47python-devsetnosy: + python-dev
messages: + msg272684
2016-08-14 16:28:23paul.mooresetnosy: + paul.moore
messages: + msg272680
2016-08-14 16:10:01brett.cannonsetassignee: steven.daprano

messages: + msg272678
nosy: + brett.cannon
2016-07-19 13:36:23steven.dapranosetfiles: + code.patch

messages: + msg270825
2016-07-19 13:34:59steven.dapranosetfiles: - code.patch
2016-07-19 12:55:40steven.dapranocreate