This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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

Created on 2010-07-21 20:44 by midnightdf, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
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.
msg370426 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-05-31 12:02
In Python 3:

TypeError: f() missing 1 required positional argument: 'a'
History
Date User Action Args
2022-04-11 14:57:04adminsetgithub: 53572
2020-05-31 12:02:04serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg370426

resolution: out of date
stage: test needed -> resolved
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