[Python-bugs-list] [ python-Bugs-405999 ] getopt: extra args behavior wrong
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 18 Mar 2001 08:27:19 -0800
Bugs item #405999, was updated on 2001-03-05 03:42
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=405999&group_id=5470
>Category: Documentation
Group: None
Status: Open
Priority: 5
Submitted By: Gregor Hoffleit (flight)
>Assigned to: Moshe Zadka (moshez)
Summary: getopt: extra args behavior wrong
Initial Comment:
[Forwarded from the Debian bug tracking system,
Bug#87722]
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=87722&repeatmerged=yes
Sender: Wichert Akkerman <wichert@cistron.nl>
getopt claims to behave just like GNU getopt, but it
does not. If I use
this code snippet:
------------------------------------------------------------------------------
(opt,args) = getopt.getopt(sys.argv[1:], 'ab')
print "Options decoded: " + string.join(map(lambda x:
x[0], opt), ', ')
print "Extra arguments: " + string.join(args, ', ')
------------------------------------------------------------------------------
Then this result is correct:
[fog;/tmp]-26> ./x.py -a -b bla
Options decoded: -a, -b
Extra arguments: bla
But this is wrong:
[fog;/tmp]-27> ./x.py -a bla -b
Options decoded: -a
Extra arguments: bla, -b
That should give the exact same result, but doesn't.
The problem seems
to be that the while loop used to iterate over the
arguments aborts
at the first non-option argument, while it should
continue to check
all arguments for possible options.
This problem persist in python2-base.
Wichert.
----------------------------------------------------------------------
>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-03-18 08:27
Message:
Logged In: YES
user_id=3066
Moshe: Your documentation update is correct; please check it in.
----------------------------------------------------------------------
Comment By: Moshe Zadka (moshez)
Date: 2001-03-18 03:46
Message:
Logged In: YES
user_id=11645
This patches clarifies the documentation, that the "GNU
behaviour" comment only holds for interpretation of --
options and *not* to the ordering problem.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=405999&group_id=5470