[issue9943] TypeError message became less helpful in Python 2.7
Mark Lawrence added the comment: 3.4.1 and 3.5.0a0 give the same message as 2.6. I don't have 2.7 to see what it currently does. -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9943 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9943] TypeError message became less helpful in Python 2.7
Terry J. Reedy added the comment: Still TypeError: f() takes exactly 0 arguments (2 given). I consider the 2.6/3.x message better (more accurate). But at this point, I could be persuaded to leave 2.7 alone and close this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9943 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9943] TypeError message became less helpful in Python 2.7
Benjamin Peterson added the comment: Yes, the argument error messages for 2.x are all not very good. Note this issue was fixed once and for all in Python 3: % python3 x.py Traceback (most recent call last): File x.py, line 3, in module f(hello, keyword=True) TypeError: f() takes 0 positional arguments but 1 was given -- resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9943 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9943] TypeError message became less helpful in Python 2.7
Terry J. Reedy tjre...@udel.edu added the comment: FWIW 3.1 gives same message as 2.6. I have not installed 3.2a yet to check that. Reporting of argument count mismatch has always been problematical, especially for methods. I almost think the message should be simplified to Arguments passed do not match function signature. Programmers who do not immediately immediately see the problem (because they know the signature but made an inadvertent mistake) will have to check the signature anyway. The alternative should be a clearer and more complete report than currently, which will take more than one line. -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9943 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9943] TypeError message became less helpful in Python 2.7
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9943 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9943] TypeError message became less helpful in Python 2.7
Geoffrey Bache gjb1...@users.sourceforge.net added the comment: I agree with Nick :) Though I'd say fixing a regression should take priority over further enhancing the messages. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9943 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9943] TypeError message became less helpful in Python 2.7
Nick Coghlan ncogh...@gmail.com added the comment: Having seen the reversion go by on the checkins list, I think there are distinctions the interpreter should be making here in order to improve the error messages, but it isn't. Ideally, we want to be able to tell the user (without writing War and Peace as an error message): 1. How many positional parameters are expected 2. How many positional parameters were supplied as positional arguments 3. How many positional parameters were supplied as keyword arguments For example: Def: f(**kw) Call: f(hello, keyword=True) Error: f() does not accept positional arguments (1 given) Def: f(x, **kw) Call: f(hello, goodbye, keyword=True) Error: f() accepts at most 1 positional argument (2 given) Def: f(x, **kw) Call: f(hello, x=goodbye, keyword=True) Error: f() accepts at most 1 positional argument (2 given, 1 via keyword) Basically: 1. Get rid of the exactly/at most distinction (exactly is wrong, since you can always provide positional arguments as keyword arguments instead) 2. Use positional instead of the awkward non-keyword 3. Append additional info when some or all of the positional arguments are provided as keywords. -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9943 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9943] TypeError message became less helpful in Python 2.7
Geoffrey Bache gjb1...@users.sourceforge.net added the comment: I think the unhelpful part is mostly that it does not distinguish between argument types any more when the distinction is important in this context. In fact, it could be argued that what it said isn't even true: f() takes exactly 0 arguments (2 given) f() doesn't take exactly 0 arguments. It takes any number of arguments, so long as they are keyword arguments. Surely you agree that the Python 2.6 error describes the problem more accurately? As for your examples, the message in the first one has changed from TypeError: f() takes exactly 1 non-keyword argument (4 given) to TypeError: f() takes exactly 1 argument (5 given) which is possibly a marginal improvement, although taken together I would say this isn't an improvement, especially as I think examples like my first one are more widespread (OK, I didn't even know this syntax was legal...) Your second example is only legal syntax in Python 3, so I don't really get the point with respect to comparing Python 2.6 and Python 2.7. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9943 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9943] TypeError message became less helpful in Python 2.7
New submission from Geoffrey Bache gjb1...@users.sourceforge.net: Consider the following code: ### keywords.py def f(**kw): print arg, kw f(hello, keyword=True) and compare the behaviour in Python 2.6 and Python 2.7: $ python keywords.py Traceback (most recent call last): File keywords.py, line 5, in module f(hello, keyword=True) TypeError: f() takes exactly 0 non-keyword arguments (1 given) $ python2.7 keywords.py Traceback (most recent call last): File keywords.py, line 5, in module f(hello, keyword=True) TypeError: f() takes exactly 0 arguments (2 given) The error message from 2.6 is I would say a more accurate description of the situation. -- components: Interpreter Core messages: 117327 nosy: gjb1002 priority: normal severity: normal status: open title: TypeError message became less helpful in Python 2.7 type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9943 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9943] TypeError message became less helpful in Python 2.7
Benjamin Peterson benja...@python.org added the comment: r85003 Thanks for the report. -- nosy: +benjamin.peterson resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9943 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9943] TypeError message became less helpful in Python 2.7
Benjamin Peterson benja...@python.org added the comment: Reverted, however. Let me clarify: you think the unhelpful part is that the count includes keyword arguments? This change was intentional, actually wrt to cases like this: def f(a): ...pass f(6, a=4, *(1, 2, 3)) Traceback (most recent call last): ... TypeError: f() takes exactly 1 positional argument (5 given) def f(a, *, kw): ...pass f(6, 4, kw=4) Traceback (most recent call last): ... TypeError: f() takes exactly 1 positional argument (3 given) -- resolution: fixed - status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9943 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com