[Bug 1048710] Re: Regression in argparse for Python 2.7, 3.2 and 3.3
Launchpad Bug Tracker
1048710 at bugs.launchpad.net
Sat Sep 15 10:20:09 UTC 2012
This bug was fixed in the package python2.7 - 2.7.3-5ubuntu2
---------------
python2.7 (2.7.3-5ubuntu2) quantal; urgency=low
* Update to 20120915, taken from the 2.7 branch. Posix relevant patches:
- Issue #15906: Fix a regression in argparse caused by the preceding change,
when action='append', type='str' and default=[]. LP: #1048710.
- Issue #15908: Fix misbehaviour of the sha1 module when called on data
larger than 2**32 bytes.
- Issue #15910: Fix misbehaviour of _md5 and sha1 modules when "updating"
on data larger than 2**32 bytes.
-- Matthias Klose <doko at ubuntu.com> Sat, 15 Sep 2012 12:11:28 +0200
** Changed in: python2.7 (Ubuntu)
Status: Confirmed => Fix Released
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python2.7 in Ubuntu.
https://bugs.launchpad.net/bugs/1048710
Title:
Regression in argparse for Python 2.7, 3.2 and 3.3
Status in Python:
Fix Released
Status in “python2.7” package in Ubuntu:
Fix Released
Status in “python3.2” package in Ubuntu:
Fix Released
Bug description:
Using the following example:
---
#!/usr/bin/python
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test", dest="test", type=str,
default=[], action='append')
args = parser.parse_args()
args.test.append("something")
---
Then running it with simply "python test.py" (WITHOUT passing --test), you get the following:
Traceback (most recent call last):
File "test.py", line 11, in <module>
args.test.append("something")
AttributeError: 'str' object has no attribute 'append'
My understanding of argparse is that when using both default=[] and
action="append", args.test should always be a list, empty if not
passing --test or a list containing the --test values if passed. After
the recent update, it seems to instead default to an empty string.
This must somehow be related to the type field as for some reason,
removing "type=str" fixes the issue though I don't really see why and
it's still a clear regression.
To manage notifications about this bug go to:
https://bugs.launchpad.net/python/+bug/1048710/+subscriptions
More information about the foundations-bugs
mailing list