classification
Title: Error message for incorrect number of (function) args is incorrect
Type: behavior Stage: test needed
Components: Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: arigo, benjamin.peterson, midnightdf, r.david.murray
Priority: normal Keywords:

Created on 2010-07-21 20:44 by midnightdf, last changed 2011-05-30 15:20 by benjamin.peterson.

Messages (5)
msg111116 - (view) Author: Dave Fugate (midnightdf) Date: 2010-07-21 20:44
The error message below should state something along the lines of "f() takes at least 1 non-keyword argument (0 given)".  Regardless, this is a regression from 2.6 which would have emitted "f() takes at least 1 argument (0 given)" which while not perfect, is a more accurate description of the problem:


D:\rft\vsl\dlr\Languages\IronPython\Tests>27
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(a, b=2): pass
...
>>> f(b=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: f() takes at least 1 argument (1 given)
>>>
msg111117 - (view) Author: Dave Fugate (midnightdf) Date: 2010-07-21 20:46
Actually CPython 2.6 emits precisely what I'd expect:
D:\rft\vsl\dlr\Languages\IronPython\Tests>26
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(a, b=2): pass
...
>>> f(b=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: f() takes at least 1 non-keyword argument (0 given)
msg111141 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-07-22 00:43
Benjamin was the last one who worked on this code (in issue 6474), adding him to nosy.
msg137291 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2011-05-30 15:16
FWIW, this case is tested in PyPy: http://paste.pocoo.org/show/397732/
msg137292 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-05-30 15:20
I think some one should just rewrite this code from scratch. Every time I fix something, it breaks something else.
History
Date User Action Args
2011-05-30 15:20:56benjamin.petersonsetmessages: + msg137292
2011-05-30 15:16:33arigosetnosy: + arigo
messages: + msg137291
2010-07-22 00:43:50r.david.murraysetnosy: + r.david.murray, benjamin.peterson

messages: + msg111141
stage: test needed
2010-07-21 20:46:10midnightdfsetmessages: + msg111117
2010-07-21 20:44:05midnightdfcreate