Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code.interact() should print an exit message #71760

Closed
stevendaprano opened this issue Jul 19, 2016 · 12 comments
Closed

code.interact() should print an exit message #71760

stevendaprano opened this issue Jul 19, 2016 · 12 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@stevendaprano
Copy link
Member

BPO 27573
Nosy @brettcannon, @arigo, @pfmoore, @ned-deily, @stevendaprano
Files
  • code.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/stevendaprano'
    closed_at = <Date 2016-08-15.01:20:09.108>
    created_at = <Date 2016-07-19.12:55:40.719>
    labels = ['type-feature', 'library']
    title = 'code.interact() should print an exit message'
    updated_at = <Date 2016-08-23.16:41:03.142>
    user = 'https://github.com/stevendaprano'

    bugs.python.org fields:

    activity = <Date 2016-08-23.16:41:03.142>
    actor = 'python-dev'
    assignee = 'steven.daprano'
    closed = True
    closed_date = <Date 2016-08-15.01:20:09.108>
    closer = 'steven.daprano'
    components = ['Library (Lib)']
    creation = <Date 2016-07-19.12:55:40.719>
    creator = 'steven.daprano'
    dependencies = []
    files = ['43793']
    hgrepos = []
    issue_num = 27573
    keywords = ['patch']
    message_count = 12.0
    messages = ['270822', '270825', '272678', '272680', '272684', '272687', '273016', '273019', '273021', '273022', '273459', '273485']
    nosy_count = 6.0
    nosy_names = ['brett.cannon', 'arigo', 'paul.moore', 'ned.deily', 'steven.daprano', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue27573'
    versions = ['Python 3.6']

    @stevendaprano
    Copy link
    Member Author

    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.

    @stevendaprano stevendaprano added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jul 19, 2016
    @stevendaprano
    Copy link
    Member Author

    This time, with a patch that includes updated tests.

    @brettcannon
    Copy link
    Member

    LGTM

    @pfmoore
    Copy link
    Member

    pfmoore commented Aug 14, 2016

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 14, 2016

    New changeset 9410dc027505 by Steven D'Aprano in branch 'default':
    bpo-27573 code.interact prints a message when exiting.
    https://hg.python.org/cpython/rev/9410dc027505

    @ned-deily
    Copy link
    Member

    Steven, don't forget to update Misc/NEWS and to close this issue on the bug tracker. Thanks!

    @arigo
    Copy link
    Mannequin

    arigo mannequin commented Aug 18, 2016

    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).

    @stevendaprano
    Copy link
    Member Author

    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.

    @arigo
    Copy link
    Mannequin

    arigo mannequin commented Aug 18, 2016

    I'm fine with exitmsg. I guess it would be a flag (not None as you wrote), defaulting to True?

    @arigo
    Copy link
    Mannequin

    arigo mannequin commented Aug 18, 2016

    ...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...)

    @stevendaprano
    Copy link
    Member Author

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 23, 2016

    New changeset c4863530cfd6 by Steven D'Aprano in branch 'default':
    Issue bpo-27573 make the exit message configurable.
    https://hg.python.org/cpython/rev/c4863530cfd6

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants