Message324407
Technically it's possible that the dictionary mutates itself during iterating and so that it's size change, so "nk = i / 2;" make sure that we pass the proper length to the function call.
Maybe I'm wrong, but we would need an unit test for that.
While I reworked a lot of code in call.c (and I moved code to call.c ;-)), this specific statement already existed before my work. I moved it from somewhere else. Extract of Objects/funcobject.c:
static PyObject *
function_call(PyObject *func, PyObject *arg, PyObject *kw)
{
...
if (kw != NULL && PyDict_Check(kw)) {
...
while (PyDict_Next(kw, &pos, &k[i], &k[i+1])) {
Py_INCREF(k[i]);
Py_INCREF(k[i+1]);
i += 2;
}
nk = i/2;
}
...
}
It seems like the code is quite old :-)
commit 6d6c1a35e08b95a83dbe47dbd9e6474daff00354
Author: Tim Peters <tim.peters@gmail.com>
Date: Thu Aug 2 04:15:00 2001 +0000
Merge of descr-branch back into trunk. |
|
Date |
User |
Action |
Args |
2018-08-31 08:26:09 | vstinner | set | recipients:
+ vstinner, serhiy.storchaka, Eric Lippert |
2018-08-31 08:26:09 | vstinner | set | messageid: <1535703969.53.0.56676864532.issue34551@psf.upfronthosting.co.za> |
2018-08-31 08:26:09 | vstinner | link | issue34551 messages |
2018-08-31 08:26:09 | vstinner | create | |
|