[New-bugs-announce] [issue18943] argparse: default args in mutually exclusive groups

Armin Rigo report at bugs.python.org
Fri Sep 6 11:00:02 CEST 2013


New submission from Armin Rigo:

In argparse, default arguments have a strange behavior that shows up in mutually exclusive groups: specifying explicitly on the command-line an argument, but giving it its default value, is sometimes equivalent to not specifying the argument at all, and sometimes not.

See the attached test diff: it contains two apparently equivalent pieces of code, but one passes and one fails.  The difference is that, in CPython, int("42") is 42 but int("4200") is not 4200 (in the sense of the operator "is").

The line that uses "is" in this way is this line in argparse.py (line 1783 in 2.7 head):

            if argument_values is not action.default:

----------
files: test_argparse.diff
keywords: patch
messages: 197058
nosy: arigo
priority: normal
severity: normal
status: open
title: argparse: default args in mutually exclusive groups
versions: Python 2.7, Python 3.5
Added file: http://bugs.python.org/file31626/test_argparse.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18943>
_______________________________________


More information about the New-bugs-announce mailing list