This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Charles Daffern
Recipients Charles Daffern
Date 2016-01-25.11:25:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Example code demonstrating the problem:

# {{{
import argparse

def try_args(*args):
    parser = argparse.ArgumentParser()
    print("Trying:", args)
    except SystemExit:

try_args("-a", "-")  # Works fine
try_args("-a", "-a")  # Breaks
try_args("-a", "--")  # Breaks
try_args("-a", "--things--")  # Breaks
# }}}

This behaviour is contrary to optparse:

# {{{
import optparse

def try_args(*args):
    parser = optparse.OptionParser()
    print("Trying:", args)
    except SystemExit:

try_args("-a", "-")  # Works
try_args("-a", "-a")  # Works
try_args("-a", "--")  # Works
try_args("-a", "--things--")  # Works
# }}}

It is also contrary to many other utilities, including python itself:

# {{{
$ python -c -c
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'c' is not defined
$ printf 'hello\nworld\n-- pick me\netc\n' | grep -e --
-- pick me
$ gawk -f --
gawk: fatal: can't open source file `--' for reading (No such file or directory)
$ vim -u --
E282: Cannot read from "--"
Press ENTER or type command to continue
$ man -M --asdf man
No manual entry for man
$ less -b --sdfkds
Number is required after -b (--buffers)
Missing filename ("less --help" for help)
$ perl -e --fasd
Can't modify constant item in predecrement (--) at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
# }}}

I first encountered this problem when using a text scrolling utility someone had written in python, and tried to pass "--" as the text separator. The program just bailed out, and it turned out that it wasn't the author's fault but a problem in argparse itself.
Date User Action Args
2016-01-25 11:25:35Charles Daffernsetrecipients: + Charles Daffern
2016-01-25 11:25:35Charles Daffernsetmessageid: <>
2016-01-25 11:25:35Charles Daffernlinkissue26196 messages
2016-01-25 11:25:33Charles Dafferncreate