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.
Created on 2012年11月20日 22:36 by chris.jerdonek, last changed 2022年04月11日 14:57 by admin.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue16515.diff | ezio.melotti, 2012年11月21日 16:06 | Patch against 3.2. | ||
| issue16515-unpacktuple.diff | ezio.melotti, 2012年11月21日 18:02 | Patch against 3.2 to fix the message in PyArg_UnpackTuple. | ||
| Messages (7) | |||
|---|---|---|---|
| msg176034 - (view) | Author: Chris Jerdonek (chris.jerdonek) * (Python committer) | Date: 2012年11月20日 22:36 | |
The below should probably say something along the lines of "max expected 1 positional arguments" (since the foo value is an argument): >>> max(foo=1) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: max expected 1 arguments, got 0 I imagine this affects other functions, but I haven't looked into which ones. Here is an example of another built-in function that provides a better message: >>> sorted(foo=1) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Required argument 'iterable' (pos 1) not found |
|||
| msg176044 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2012年11月21日 08:18 | |
It would be nice to change 'arguments' to 'argument' in this case, too. :-) |
|||
| msg176063 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2012年11月21日 16:06 | |
Attached an initial patch: >>> max() TypeError: max() requires at least a positional argument >>> max(foo=3) TypeError: max() requires at least a positional argument >>> max(3, foo=3) TypeError: max() got an unexpected keyword argument >>> max(3, 4) 4 |
|||
| msg176067 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2012年11月21日 17:51 | |
Would it make sense to adjust the error messages in PyArg_UnpackTuple instead? I suspect there are quite a lot of functions using it. |
|||
| msg176068 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2012年11月21日 18:02 | |
PyArg_UnpackTuple could be fixed to say "positional argument" (see attached patch (maybe this should be a separate issue)). The error returned by max() is wrong because PyArg_UnpackTuple is used on the *args alone first, and it has no knowledge of the kwargs. If PyArg_UnpackTuple is used to parse the *args then adding "positional" should solve the problem, however for this specific case the error would still be incorrect, because max also accepts more positional args. |
|||
| msg176070 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2012年11月21日 18:12 | |
Yes, true: max is probably still going to have to be a special case, thanks to its schizophrenic signature. (max([1, 2, 3]) versus max(1, 2, 3)). |
|||
| msg176204 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2012年11月23日 18:07 | |
I created #16543 for PyArg_UnpackTuple. Once that is fixed we can continue with this. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:38 | admin | set | github: 60719 |
| 2020年10月22日 18:35:07 | iritkatriel | set | versions: + Python 3.8, Python 3.9, Python 3.10, - Python 2.7, Python 3.2, Python 3.3, Python 3.4 |
| 2012年11月23日 18:07:53 | ezio.melotti | set | dependencies:
+ improve TypeError messages for missing arguments (meta issue) messages: + msg176204 |
| 2012年11月21日 18:12:21 | mark.dickinson | set | messages: + msg176070 |
| 2012年11月21日 18:02:33 | ezio.melotti | set | files:
+ issue16515-unpacktuple.diff messages: + msg176068 |
| 2012年11月21日 17:51:24 | mark.dickinson | set | messages: + msg176067 |
| 2012年11月21日 16:06:23 | ezio.melotti | set | files:
+ issue16515.diff keywords: + patch messages: + msg176063 stage: needs patch -> patch review |
| 2012年11月21日 15:39:32 | ezio.melotti | set | nosy:
+ ezio.melotti stage: needs patch |
| 2012年11月21日 08:18:06 | mark.dickinson | set | nosy:
+ mark.dickinson messages: + msg176044 |
| 2012年11月20日 23:24:40 | chris.jerdonek | set | title: TypeError message incorrect for max() with no args -> TypeError message incorrect for max() with one keyword arg |
| 2012年11月20日 22:36:57 | chris.jerdonek | create | |