STINNER Victor added the comment:

Oh, this issue is very subtle.

Since the list.sorted() class method became a builtin sorted() method (Python 
2.4.0, change c06b570adf12 by Raymond Hettinger), the sorted() function accepts 
an iterable as a keyword argument, whereas list.sort() doesn't. 
sorted(iterable=[]) fails on calling internally list.sort(iterable=[]), not 
when sorted() parses its arguments.

The change 6219aa966a5f (issue #20184) converted sorted() to Argument Clinic. 
This change was released in Python 3.5.3 and 3.6.0... but it didn't introduce 
the bug. It's not the fault of Argument Clinic!

The change b34d2ef5c412 (issue #27809) replacing METH_VARARGS|METH_KEYWORDS 
with METH_FASTCALL didn't introduce the bug neither.

It's the change 15eab21bf934 (issue #27809) which replaced 
PyEval_CallObjectWithKeywords() with _PyObject_FastCallDict(). This change also 
replaces PyTuple_GetSlice(args, 1, argc) with &PyTuple_GET_ITEM(args, 1) which 
introduced the bug. I didn't notice that args can be an empty tuple. I never 
tried to call sorted(iterable=seq), I didn't know the name of the first 
parameter :-)

I also replaced PyTuple_GetSlice(args, 1, argc) with &PyTuple_GET_ITEM(args, 1) 
in methoddescr_call(), but this function make sure that we have at least one 
positional argument and so doesn't have this bug. Moreover, this method doesn't 
use Argument Clinic (yet? ;-)). I'm quite sure that I didn't replace 
PyTuple_GetSlice() in other functions.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29327>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to