Martin Panter added the comment: In Python 3.5, this does not seem fixed. Issue 13922 is marked as resolved and fixed, but Pauls’s patch has not actually been committed.
>>> ap = ArgumentParser() >>> ap.add_argument("-t", "--test", type=str, nargs=1) _StoreAction(option_strings=['-t', '--test'], dest='test', nargs=1, const=None, default=None, type=<class 'str'>, choices=None, help=None, metavar=None) >>> ap.add_argument('yuri', nargs='?') _StoreAction(option_strings=[], dest='yuri', nargs='?', const=None, default=None, type=None, choices=None, help=None, metavar=None) >>> ap.parse_args(["--test=--", "foo"]) Namespace(test=[], yuri='foo') >>> ap.parse_args(["--test", "--", "foo"]) usage: [-h] [-t TEST] [yuri] : error: argument -t/--test: expected 1 argument argparse.ArgumentError: argument -t/--test: expected 1 argument During handling of the above exception, another exception occurred: __main__.SystemExit: 2 >>> ap.parse_args(["-t--", "foo"]) Namespace(test=[], yuri='foo') >>> ap.parse_args(["-t", "--", "foo"]) usage: [-h] [-t TEST] [yuri] : error: argument -t/--test: expected 1 argument argparse.ArgumentError: argument -t/--test: expected 1 argument During handling of the above exception, another exception occurred: __main__.SystemExit: 2 ---------- nosy: +martin.panter title: Argparse incorrectly handles '--' -> Argparse incorrectly handles '--' as argument to option _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue14364> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com