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.

Author vstinner
Recipients rhettinger, serhiy.storchaka, vstinner
Date 2017-01-19.22:20:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1484864443.52.0.664068494114.issue29327@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-01-19 22:20:43vstinnersetrecipients: + vstinner, rhettinger, serhiy.storchaka
2017-01-19 22:20:43vstinnersetmessageid: <1484864443.52.0.664068494114.issue29327@psf.upfronthosting.co.za>
2017-01-19 22:20:43vstinnerlinkissue29327 messages
2017-01-19 22:20:43vstinnercreate