classification
Title: Multiple error line for unknown command line parameter
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.4, Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: ezio.melotti, hieu.nguyen, pitrou, python-dev, serhiy.storchaka, skrah, tweksteen
Priority: normal Keywords: easy, patch

Created on 2012-10-23 23:47 by tweksteen, last changed 2012-11-23 19:14 by ezio.melotti. This issue is now closed.

Files
File name Uploaded Description Edit
issue16306.patch hieu.nguyen, 2012-10-24 22:42 review
issue16306_py3.patch hieu.nguyen, 2012-10-25 21:29 review
issue16306_py27.patch hieu.nguyen, 2012-10-25 21:29 review
test_unknown_option.patch serhiy.storchaka, 2012-11-23 09:04 Patch for 3.x review
test_unknown_option-2.7.patch serhiy.storchaka, 2012-11-23 09:07 Patch for 2.7 review
test_unknown_option_2.patch serhiy.storchaka, 2012-11-23 15:50 Patch for 3.x review
test_unknown_option_2-2.7.patch serhiy.storchaka, 2012-11-23 15:51 Patch for 2.7 review
Messages (17)
msg173649 - (view) Author: Thiébaud Weksteen (tweksteen) Date: 2012-10-23 23:47
Hi,

I've just came across an insignificant bug in the Python command line 
interface. When using an unknown parameter, the same error appears 
more than once:

$ python3 -a -z
Unknown option: -a
Unknown option: -z
Unknown option: -a
usage: python3 [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
$ python -a -z
Unknown option: -a
Unknown option: -z
Unknown option: -a
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
msg173716 - (view) Author: Hieu Nguyen (hieu.nguyen) * Date: 2012-10-24 22:42
I've attached the patch for this issue, including the test.
msg173801 - (view) Author: Hieu Nguyen (hieu.nguyen) * Date: 2012-10-25 21:29
Submitted another patchs for py3k and python 2.7
msg173805 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-10-25 22:50
LGTM.
msg174193 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-10-30 10:00
Hieu Nguyen, can you please submit a contributor form?

http://python.org/psf/contrib/contrib-form/
http://python.org/psf/contrib/
msg174199 - (view) Author: Hieu Nguyen (hieu.nguyen) * Date: 2012-10-30 10:25
Serhiy, actually I have submitted my contributor form to Petri Lehtinen in  a sprint here in Finland.
msg175868 - (view) Author: Roundup Robot (python-dev) Date: 2012-11-18 12:07
New changeset d2df83d7c649 by Ezio Melotti in branch '2.7':
#16306: Fix multiple error messages when unknown command line parameters where passed to the interpreter.  Patch by Hieu Nguyen.
http://hg.python.org/cpython/rev/d2df83d7c649

New changeset 0153c077a0fd by Ezio Melotti in branch '3.2':
#16306: Fix multiple error messages when unknown command line parameters where passed to the interpreter.  Patch by Hieu Nguyen.
http://hg.python.org/cpython/rev/0153c077a0fd

New changeset 7f01121a660d by Ezio Melotti in branch '3.3':
#16306: merge with 3.2.
http://hg.python.org/cpython/rev/7f01121a660d

New changeset 3a1bcb6de167 by Ezio Melotti in branch 'default':
#16306: merge with 3.3.
http://hg.python.org/cpython/rev/3a1bcb6de167
msg175869 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-18 12:08
Fixed, thanks for the patch!
msg176130 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-11-22 22:09
You broke the Ubuntu Shared buildbot, could you fix it?
http://buildbot.python.org/all/buildslaves/bolen-ubuntu
msg176155 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-23 09:04
Sorry, it's my fault. Here is a patch which should fix the bug.
msg176156 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-23 09:07
Actually 2.7 tests should not be broken, but this patch unify 2.7 and 3.x code.
msg176175 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-23 15:02
The new patch doesn't seem to be correct:
without the patch:
$ ./python -a -z
Unknown option: -a
Unknown option: -z
usage: ./python [option] ... [-c cmd | -m mod | file | -] [arg] ...

with the patch:
$ ./python -a -z
Unknown option: -a
usage: ./python [option] ... [-c cmd | -m mod | file | -] [arg] ...

A test case for this should also be added.
msg176177 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-23 15:50
Thanks, Ezio, for point.

> without the patch:
> $ ./python -a -z
> Unknown option: -a
> Unknown option: -z
> usage: ./python [option] ... [-c cmd | -m mod | file | -] [arg] ...

This behavior isn't correct. Try also "-E -a -z" and "-a -E -z" (also with 3.3.0).

However I found an error in the test in my patch (actually previous test for 2.7 was correct, but not full). Patch updated, new tests added.
msg176178 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-23 15:56
> This behavior isn't correct.

Shouldn't python report all the invalid flags passed?
msg176179 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-23 15:59
Should not. It happened unintentionally (and inconsistently).
msg176185 - (view) Author: Roundup Robot (python-dev) Date: 2012-11-23 17:01
New changeset 6a79e3beb854 by Ezio Melotti in branch '2.7':
#16306: report only the first unknown option and add more tests.  Patch by Serhiy Storchaka.
http://hg.python.org/cpython/rev/6a79e3beb854

New changeset 654a628f5f00 by Ezio Melotti in branch '3.2':
#16306: report only the first unknown option and add more tests.  Patch by Serhiy Storchaka.
http://hg.python.org/cpython/rev/654a628f5f00

New changeset 421a8a5ffbb2 by Ezio Melotti in branch '3.3':
#16306: merge with 3.2.
http://hg.python.org/cpython/rev/421a8a5ffbb2

New changeset 51caa0820fad by Ezio Melotti in branch 'default':
#16306: merge with 3.3.
http://hg.python.org/cpython/rev/51caa0820fad
msg176215 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-23 19:14
Buildbots are happy, closing.
Thanks Serhiy for the patches!
History
Date User Action Args
2012-11-23 19:14:32ezio.melottisetstatus: open -> closed

messages: + msg176215
2012-11-23 17:01:56python-devsetmessages: + msg176185
2012-11-23 15:59:01serhiy.storchakasetmessages: + msg176179
2012-11-23 15:56:24ezio.melottisetmessages: + msg176178
2012-11-23 15:51:29serhiy.storchakasetfiles: + test_unknown_option_2-2.7.patch
2012-11-23 15:50:40serhiy.storchakasetfiles: + test_unknown_option_2.patch

messages: + msg176177
2012-11-23 15:02:54ezio.melottisetmessages: + msg176175
2012-11-23 09:07:08serhiy.storchakasetfiles: + test_unknown_option-2.7.patch

messages: + msg176156
2012-11-23 09:04:25serhiy.storchakasetfiles: + test_unknown_option.patch
nosy: + skrah
messages: + msg176155

2012-11-22 23:42:48ezio.melottilinkissue16536 superseder
2012-11-22 22:09:49pitrousetstatus: closed -> open
nosy: + pitrou
messages: + msg176130

2012-11-18 12:08:36ezio.melottisetstatus: open -> closed
messages: + msg175869

assignee: ezio.melotti
resolution: fixed
stage: commit review -> resolved
2012-11-18 12:07:14python-devsetnosy: + python-dev
messages: + msg175868
2012-10-30 10:25:01hieu.nguyensetmessages: + msg174199
2012-10-30 10:00:41serhiy.storchakasetmessages: + msg174193
2012-10-25 22:50:41serhiy.storchakasetnosy: + serhiy.storchaka

messages: + msg173805
stage: commit review
2012-10-25 21:29:55hieu.nguyensetfiles: + issue16306_py27.patch
2012-10-25 21:29:44hieu.nguyensetfiles: + issue16306_py3.patch

messages: + msg173801
2012-10-24 22:42:15hieu.nguyensetfiles: + issue16306.patch

nosy: + hieu.nguyen
messages: + msg173716

keywords: + patch
2012-10-24 21:26:35ezio.melottisetnosy: + ezio.melotti
2012-10-24 01:09:00r.david.murraysetkeywords: + easy
components: + Interpreter Core, - None
versions: + Python 3.3, Python 3.4
2012-10-23 23:47:11tweksteencreate