Visitar URL original
bpython quits when parsing empty arguments with argparse module · Issue #745 · bpython/bpython · GitHub
Skip to content

bpython quits when parsing empty arguments with argparse module #745

Description

@bfrascher

I was testing around some things with the argparse module in bpython when suddenly bpython quit on me with error code 1. I tried to break the problem down and the code below seems to be the minimal reproducer:

$ bpython
bpython version 0.17.1 on top of Python 3.7.0 /usr/bin/python
>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('foo')
_StoreAction(option_strings=[], dest='foo', nargs=None, const=None, default=None, type=None, choices=None, help=None, metavar=None)
>>> parser.parse_args()
usage: bpython [-h] foo
>>> parser.parse_args()
(2,)
$ echo $?
1

The second parser.parse_args() is not entered by me, but appears automatically on executing the first parser.parse_args() line.

Activity

  1. sebastinas commented on Jan 3, 2020

    @sebastinas
    Contributor

    That's almost consistent with python's behavior. In fact, it should already quit after the first call of parse_args():

    % python3
    Python 3.7.3 (default, Apr  3 2019, 05:39:12) [GCC 8.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import argparse
    >>> parser = argparse.ArgumentParser()
    >>> parser.add_argument('foo')
    _StoreAction(option_strings=[], dest='foo', nargs=None, const=None, default=None, type=None, choices=None, help=None, metavar=None)                                                                                                           
    >>> parser.parse_args()
    usage: [-h] foo
    : error: the following arguments are required: foo
    %
    

    So, there is a bug, but a different one.

  2. self-assigned this
    on Apr 11, 2020
  3. added this to the release-0.20 milestone on Apr 11, 2020
  4. removed their assignment
    on Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions