paul j3 added the comment:
http://bugs.python.org/issue9571 proposes a refinement to this patch - drop the
'--' from PARSER and REMAINDER nargs if it is the 1st string.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13922
Changes by Michele Orrù maker...@gmail.com:
--
nosy: +maker
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13922
___
___
Python-bugs-list mailing
paul j3 added the comment:
This patch removes only one '--', the one that put a '-' in the
'arg_strings_pattern'. It does this in 'consume_positionals' right before
calling 'take_action'. As before it does not do this if nargs is PARSER or
REMAINDER.
test_argparse.py has two
paul j3 added the comment:
I am working on an alternative solution that moves the '--' removal to the
consume_positionals() method, and only does it if there is a corresponding '-'
in the arg_strings_pattern.
--
___
Python tracker
paul j3 added the comment:
There are several problems with the patch provided in msg156315
This description:
Added patch so that only the first '--' is removed by an argparse.PARSE or
argparse.REMAINDER argument.
should read
Added patch so that only the first '--' is removed by arguments
paul j3 added the comment:
There's another 'feature' to the patch proposed here. It only deletes the
first '--' in the list of strings passed to '_get_values' for a particular
action.
parser = argparse.ArgumentParser()
parser.add_argument('foo')
parser.add_argument('bar',
Roundup Robot added the comment:
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
George-Cristian Bîrzan added the comment:
This patch introduced a regression. Before, parse_args would take a tuple as an
argument, and in _get_values it was converted to a list via list comprehension,
which meant it was working with tuples too. In the current version, that raises
an
Steven Bethard added the comment:
@gcbirzan: Could you please open up a new issue? The current issue is fixed -
it's just that the fix caused a new issue.
I would say that the `args` parameter was never intended to be anything but a
list, so currently there's a documentation bug since that
Steven Bethard steven.beth...@gmail.com added the comment:
This patch looks like the right fix to me. The tests look good too.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13922
___
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset 18b114be013e by R David Murray in branch '3.2':
#13922: argparse no longer incorrectly strips '--' after the first one.
http://hg.python.org/cpython/rev/18b114be013e
New changeset bd2c167dfabc by R David Murray in
R. David Murray rdmur...@bitdance.com added the comment:
Committed. Thanks, Jeff. By the way, although this patch isn't big enough to
require it, it would be great if you would submit a contributor agreement:
http://www.python.org/psf/contrib.
--
resolution: - fixed
stage: -
Warren Turkal w...@penguintechs.org added the comment:
Thanks for fixing this issue. You guys are great!
wt
On Sat, Jul 21, 2012 at 8:00 PM, R. David Murray rep...@bugs.python.orgwrote:
R. David Murray rdmur...@bitdance.com added the comment:
Committed. Thanks, Jeff. By the way,
R. David Murray rdmur...@bitdance.com added the comment:
I think it is unlikely that anyone depends on argparse consuming multiple --
strings. If you are worried about it we could restrict the change to 3.3. But
personally I think this would be OK for a bug fix.
--
nosy:
Steven Bethard steven.beth...@gmail.com added the comment:
Ok, I agree - I'm fine with it as a bugfix. Depending on the removal of extra
-- strings would be pretty crazy anyway. ;-)
--
___
Python tracker rep...@bugs.python.org
Jeff Knupp jkn...@gmail.com added the comment:
I don't know that this is a bug. Rather, the string '--' means different things
to argparse and optparse. In argparse, '--' is a psuedo-argument taken to mean
everything after this is a postional argument and not stop processing
arguments, which
R. David Murray rdmur...@bitdance.com added the comment:
No, it is definitely a bug. It prevents implementing parsers that pass strings
on to another sub-parser or command. Imagine, for example, implementing a
script that takes some arguments, but takes the entire rest of the command
string
Eric V. Smith e...@trueblade.com added the comment:
I agree with David. It's a bug. I have programs (not using argparse yet) that
do exactly what he describes.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13922
Jeff Knupp jkn...@gmail.com added the comment:
In that case, wouldn't you use 'parse_known_args' instead of 'parse_args'
and pass the remaining arguments to the next script? This case is
explicitly mentioned in the argparse documentation. Again it seems to me
that the meaning of '--' has changed
Eric V. Smith e...@trueblade.com added the comment:
No. parse_known_args assumes you have known and unknown args intermixed.
Going back to the original example, what if hack and :target had
overlapping parameter names (say, they both supported --arg1)? I think
parse_known_args would pick up
Steven Bethard steven.beth...@gmail.com added the comment:
It prevents implementing parsers that pass strings on to another
sub-parser or command.
...
wouldn't you use 'parse_known_args' instead of 'parse_args'
and pass the remaining arguments to the next script
I'll just say again that
Jeff Knupp jkn...@gmail.com added the comment:
Added patch so that only the first '--' is removed by an argparse.PARSE or
argparse.REMAINDER argument. Note that, as Steven said, argparse.REMAINDER
should be used in the OP's issue (and the added test makes sure all remaining
arguments are
Warren Turkal w...@penguintechs.org added the comment:
Using argparse.REMAINDER will not help for my problem in my real program as the
first arg needs to be handled by my program and mapped into the real binary
name.
If I recall correctly from memory, the following is what happened when I
Steven Bethard steven.beth...@gmail.com added the comment:
See nargs=argparse.REMAINDER for an approach that doesn't require that first
'--':
http://docs.python.org/library/argparse.html#nargs
But yeah, removing more than one '--' is probably a bug. Fixing it would be a
little backwards
Christophe Kalt k...@taranis.org added the comment:
Hah.. was just about to report this. I'm in the midst of converting a bunch of
scripts from optparse to argparse, and this is one of the problems I'm hitting.
--
nosy: +kalt
___
Python tracker
Changes by Warren Turkal w...@penguintechs.org:
--
versions: +Python 3.3, Python 3.4
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13922
___
___
Warren Turkal w...@penguintechs.org added the comment:
I wanted to include a minimal example script, so here it is. If you run this
like so:
$ ./test.py -- blah -- blah2
you will get the the following output:
Namespace(args=['blah2'], target=['blah'])
I would have expected the following
Warren Turkal w...@penguintechs.org added the comment:
It doesn't look like that file got included last time, so here's a second try.
--
Added file: http://bugs.python.org/file24424/test.py
___
Python tracker rep...@bugs.python.org
Changes by Eric V. Smith e...@trueblade.com:
--
nosy: +bethard, eric.smith
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13922
___
___
New submission from Warren Turkal w...@penguintechs.org:
I have a program that runs something like the following:
$ hack run -- :target --arg1 --arg2 arg3 arg4
This basically runs a program identified by :target with the args. However, I
cannot pass -- to the program. For example, if I type:
$
30 matches
Mail list logo