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

InteractiveConsole does not support -q option #66165

Closed
abalkin opened this issue Jul 12, 2014 · 13 comments
Closed

InteractiveConsole does not support -q option #66165

abalkin opened this issue Jul 12, 2014 · 13 comments
Assignees
Labels
easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@abalkin
Copy link
Member

abalkin commented Jul 12, 2014

BPO 21966
Nosy @abalkin, @benjaminp, @bitdancer, @swarmer
Files
  • code.patch
  • code_flags_argparse.patch
  • code_flags_argparse_v2.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/abalkin'
    closed_at = <Date 2014-07-12.20:38:01.865>
    created_at = <Date 2014-07-12.16:05:23.710>
    labels = ['easy', 'type-feature', 'library']
    title = 'InteractiveConsole does not support -q option'
    updated_at = <Date 2014-07-12.20:38:01.864>
    user = 'https://github.com/abalkin'

    bugs.python.org fields:

    activity = <Date 2014-07-12.20:38:01.864>
    actor = 'belopolsky'
    assignee = 'belopolsky'
    closed = True
    closed_date = <Date 2014-07-12.20:38:01.865>
    closer = 'belopolsky'
    components = ['Library (Lib)']
    creation = <Date 2014-07-12.16:05:23.710>
    creator = 'belopolsky'
    dependencies = []
    files = ['35932', '35933', '35934']
    hgrepos = []
    issue_num = 21966
    keywords = ['patch', 'easy']
    message_count = 13.0
    messages = ['222850', '222862', '222863', '222865', '222866', '222867', '222868', '222869', '222870', '222871', '222872', '222880', '222882']
    nosy_count = 5.0
    nosy_names = ['belopolsky', 'benjamin.peterson', 'r.david.murray', 'python-dev', 'anton.barkovsky']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue21966'
    versions = ['Python 3.5']

    @abalkin
    Copy link
    Member Author

    abalkin commented Jul 12, 2014

    When invoked with -q option, python3 prints no banner:
    $ python3 -q

    >>

    However, code.InteractiveConsole does not implement this feature:
    $ python3 -mcode -q
    Python 3.4.1 (default, May 19 2014, 13:10:29)
    [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    (InteractiveConsole)

    >>

    @abalkin abalkin added easy type-feature A feature request or enhancement labels Jul 12, 2014
    @swarmer
    Copy link
    Mannequin

    swarmer mannequin commented Jul 12, 2014

    Here's a patch.

    @abalkin
    Copy link
    Member Author

    abalkin commented Jul 12, 2014

    That was quick! (Well - I knew it would not be hard.)

    I have two questions:

    1. How should python3 -q -mcode behave?
    2. If we add this patch, should we also attempt to emulate other command line options (-V, -h, etc.)?

    @abalkin abalkin self-assigned this Jul 12, 2014
    @abalkin abalkin added the stdlib Python modules in the Lib dir label Jul 12, 2014
    @bitdancer
    Copy link
    Member

    Whether or not other options are emulated, unimplemented ones should probably be rejected.

    @swarmer
    Copy link
    Mannequin

    swarmer mannequin commented Jul 12, 2014

    1. How should python3 -q -mcode behave?

    I've only now found out about sys.flags. I think we should check for -q both before -m and after, because why not?

    1. If we add this patch, should we also attempt to emulate other command line options (-V, -h, etc.)?

    As I see it, the module is only concerned with REPL functionality, making these options a bit out of scope.

    @abalkin
    Copy link
    Member Author

    abalkin commented Jul 12, 2014

    In order to implement reasonable rejection behavior, we probably need to add some support for -h.

    $ python3 -z
    Unknown option: -z
    usage: python3 [option] ... [-c cmd | -m mod | file | -] [arg] ...
    Try `python -h' for more information.

    I don't think we should condition acceptance of this patch on extra features.

    AFAICT, the main use of the code module is in embedded situations and the if __name__ == "__main__" behavior is mostly there for demonstration purposes.

    On the other hand, something like

    $ python3 -mcode -z
    Unknown option: -z
    usage: python3 -mcode [-q]

    is not hard to implement.

    @swarmer
    Copy link
    Mannequin

    swarmer mannequin commented Jul 12, 2014

    Here's a patch that checks both sys.flags and sys.argv and uses argparse.

    @abalkin
    Copy link
    Member Author

    abalkin commented Jul 12, 2014

    I think we should check for -q both before -m and after, because why not?

    If we check for sys.flags.quiet, wouldn't it be surprising to have

    $ python3 -mcode -q
    >>> import sys; sys.flags.quiet
    0

    @swarmer
    Copy link
    Mannequin

    swarmer mannequin commented Jul 12, 2014

    That's not a very likely scenario and I think the distinction between arguments that are passed to the script and interpreter flags is fairly obvious.

    @abalkin
    Copy link
    Member Author

    abalkin commented Jul 12, 2014

    A nitpick: banner=banner in

    + interact(banner=banner)

    is redundant.

    + interact(banner)

    would work and is just as clear.

    @swarmer
    Copy link
    Mannequin

    swarmer mannequin commented Jul 12, 2014

    Yeah, my love for keyword arguments is a bit too big sometimes.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 12, 2014

    New changeset 7f8843ec34ee by Alexander Belopolsky in branch 'default':
    Issue bpo-21966: Respect -q command-line option when code module is ran.
    http://hg.python.org/cpython/rev/7f8843ec34ee

    @abalkin
    Copy link
    Member Author

    abalkin commented Jul 12, 2014

    Committed. Thanks, Anton.

    @abalkin abalkin closed this as completed Jul 12, 2014
    @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
    easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants