[New-bugs-announce] [issue24223] argparse parsing bug

Bob Alexander report at bugs.python.org
Mon May 18 03:22:12 CEST 2015

New submission from Bob Alexander:

Here is simple example of failure to parse arguments that should parse OK. In the following little program, the second from last line contains an aargument sequence that parses OK, but the last line should but doesn't.

import argparse
ap = argparse.ArgumentParser()
ap.add_argument("--option", action="store_true")
ap.add_argument("arg_2", nargs="?")
print("test 1:", ap.parse_args(["abc", "mmm", "--option"]))
print("test 2:", ap.parse_args(["abc", "--option", "mmm"]))

components: Library (Lib)
messages: 243447
nosy: bobjalex
priority: normal
severity: normal
status: open
title: argparse parsing bug
type: behavior
versions: Python 3.4

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list