Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 82133:d296cf1600a8
evaluate positional defaults before keyword-only defaults (closes #16967)
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sun, 10 Feb 2013 09:29:59 -0500 |
| parents | cd87afe18ff8 |
| children | f1d3fbcd837d |
line wrap: on
line diff
--- a/Python/ceval.c Sun Feb 10 14:44:43 2013 +0200 +++ b/Python/ceval.c Sun Feb 10 09:29:59 2013 -0500 @@ -2901,23 +2901,6 @@ } /* XXX Maybe this should be a separate opcode? */ - if (posdefaults > 0) { - PyObject *defs = PyTuple_New(posdefaults); - if (defs == NULL) { - Py_DECREF(func); - goto error; - } - while (--posdefaults >= 0) - PyTuple_SET_ITEM(defs, posdefaults, POP()); - if (PyFunction_SetDefaults(func, defs) != 0) { - /* Can't happen unless - PyFunction_SetDefaults changes. */ - Py_DECREF(defs); - Py_DECREF(func); - goto error; - } - Py_DECREF(defs); - } if (kwdefaults > 0) { PyObject *defs = PyDict_New(); if (defs == NULL) { @@ -2945,6 +2928,23 @@ } Py_DECREF(defs); } + if (posdefaults > 0) { + PyObject *defs = PyTuple_New(posdefaults); + if (defs == NULL) { + Py_DECREF(func); + goto error; + } + while (--posdefaults >= 0) + PyTuple_SET_ITEM(defs, posdefaults, POP()); + if (PyFunction_SetDefaults(func, defs) != 0) { + /* Can't happen unless + PyFunction_SetDefaults changes. */ + Py_DECREF(defs); + Py_DECREF(func); + goto error; + } + Py_DECREF(defs); + } PUSH(func); DISPATCH(); }
