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.

classification
Title: parse_args stopped accepting tuples
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, bethard, georg.brandl, python-dev, r.david.murray, zbysz
Priority: high Keywords: patch

Created on 2012-09-02 13:12 by zbysz, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
argparse_parse_args_tuple.diff zbysz, 2012-09-02 20:51 tests and patch fixing the problem, v2
Messages (10)
msg169695 - (view) Author: Zbyszek Jędrzejewski-Szmek (zbysz) * Date: 2012-09-02 13:12
After recent change (78307 '#13922: argparse no longer incorrectly strips '--' after the first one.'), parse_args stopped working with a tuple
argument. It is easy to pass tuple to argparse by using positional function arguments:

def f(*args):
   parser.parse_args(args)

This will fail, because args is a tuple.

It is necessary to have at least one positional argument to trigger the bug.
msg169703 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-09-02 14:42
I wonder if this is problematic enough that it should be treated as a regression and fixed in the next RC?
msg169704 - (view) Author: Zbyszek Jędrzejewski-Szmek (zbysz) * Date: 2012-09-02 14:44
On Sun, Sep 02, 2012 at 02:42:34PM +0000, R. David Murray wrote:
> 
> R. David Murray added the comment:
> 
> I wonder if this is problematic enough that it should be treated as a regression and fixed in the next RC?
I believe yes, because I've already hit it in two different projects.
It is also causes susceptible programs to fail completely.

Zbyszek
msg169705 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-09-02 14:47
Let's see what Georg thinks.
msg169710 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2012-09-02 17:37
The fix looks about right to me.

There's a bug in the tests though:

    parser.parse_args(('x'))

should probably be:

    parser.parse_args(('x',))

since I assume the intent was to test tuples.
msg169723 - (view) Author: Zbyszek Jędrzejewski-Szmek (zbysz) * Date: 2012-09-02 20:52
Thanks for noticing. Replaced patch with the ('x') -> ('x',) bugfix.
msg169746 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2012-09-03 05:45
I agree this is a regression and should be fixed.
msg170033 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2012-09-08 05:58
Committed in release clone as 8c2e87aeb707.  Please apply to the main branches as usual.
msg170055 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-09-08 16:35
New changeset 5d8454fcc629 by R David Murray in branch '3.2':
#15847: allow args to be a tuple in parse_args
http://hg.python.org/cpython/rev/5d8454fcc629

New changeset 76655483c5c8 by R David Murray in branch 'default':
merge #15847: allow args to be a tuple in parse_args
http://hg.python.org/cpython/rev/76655483c5c8

New changeset a2147bbf7868 by R David Murray in branch '2.7':
#15847: allow args to be a tuple in parse_args
http://hg.python.org/cpython/rev/a2147bbf7868
msg170056 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-09-08 16:36
Thanks, Zbyszek.  I'm glad you caught this.
History
Date User Action Args
2022-04-11 14:57:35adminsetgithub: 60051
2012-09-08 16:36:44r.david.murraysetstatus: open -> closed
resolution: fixed
messages: + msg170056

stage: resolved
2012-09-08 16:35:06python-devsetnosy: + python-dev
messages: + msg170055
2012-09-08 05:58:36georg.brandlsetpriority: release blocker -> high

messages: + msg170033
2012-09-03 05:45:35georg.brandlsetmessages: + msg169746
2012-09-02 20:52:52zbyszsetmessages: + msg169723
2012-09-02 20:52:16zbyszsetfiles: - argparse_parse_args_tuple.diff
2012-09-02 20:51:52zbyszsetfiles: + argparse_parse_args_tuple.diff
2012-09-02 17:37:54bethardsetmessages: + msg169710
2012-09-02 14:47:45r.david.murraysetpriority: normal -> release blocker
nosy: + georg.brandl, benjamin.peterson
messages: + msg169705

2012-09-02 14:44:20zbyszsetmessages: + msg169704
2012-09-02 14:42:33r.david.murraysetmessages: + msg169703
2012-09-02 13:12:14zbyszcreate