[issue24556] Getopt overwrites variables unexpectedly

2015-07-03 Thread R. David Murray

R. David Murray added the comment:

This behavior is correct:

rdmurray@session:~>getopt a:b:c -a value1 -b value2 -cbanana
 -a value1 -b value2 -c -b anana --

--
nosy: +r.david.murray
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24556] Getopt overwrites variables unexpectedly

2015-07-03 Thread Jak

New submission from Jak:

The getopt library has, what I assume is, some unexpected behaviour when adding 
extra text to command line parameter that getopt expects as a flag.

Using input parameters a, b and c as an example below, where a and b both take 
values and c is a flag.

Example code:
options, remainders = getopt.getopt(sys.argv[1:], "a:b:c")

Normal output is given when you supply sensible values for a, b and c:

Input: -a value1 -b value2 -c
Output: [('-a', 'value1'), ('-b', 'value2'), ('-c', '')]

Unexpected output happens when you give extra text after the '-c' that begins 
with a letter matching that of a previous parameter:

Input -a value1 -b value2 -cbanana
Output: [('-a', 'value1'), ('-b', 'value2'), ('-c', ''), ('-b', 'anana')]

Looping through the output variables, as most example programs do, results in 
the value for '-b' being over-written.

--
components: Library (Lib)
messages: 246153
nosy: Jak
priority: normal
severity: normal
status: open
title: Getopt overwrites variables unexpectedly
type: behavior
versions: Python 2.7, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com