summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2013-02-10 14:29:59 (GMT)
committerBenjamin Peterson <benjamin@python.org>2013-02-10 14:29:59 (GMT)
commit1ef876cd28aa2f76edffb6e4d209c6a49b5705ef (patch)
treeeeb6cbf3329f73d4ddce50aef3c912b9e4aef400 /Python/ceval.c
parent34a2a87d17ff1730946adf86d23a4737271e53b3 (diff)
downloadcpython-1ef876cd28aa2f76edffb6e4d209c6a49b5705ef.zip
cpython-1ef876cd28aa2f76edffb6e4d209c6a49b5705ef.tar.gz
cpython-1ef876cd28aa2f76edffb6e4d209c6a49b5705ef.tar.bz2
evaluate positional defaults before keyword-only defaults (closes #16967)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 32c203e..d8787d3 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2901,23 +2901,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
}
/* 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 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
}
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();
}