summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2016-09-08 21:40:36 (GMT)
committerRaymond Hettinger <python@rcn.com>2016-09-08 21:40:36 (GMT)
commit262b6793e04993cb88847a3fb8dab22848cf6647 (patch)
tree7b985de4d19e233277cfbd767eb71b11034429e9 /Python
parent5dc504c3c937a160c6d09bb124df5298712a1839 (diff)
downloadcpython-262b6793e04993cb88847a3fb8dab22848cf6647.zip
cpython-262b6793e04993cb88847a3fb8dab22848cf6647.tar.gz
cpython-262b6793e04993cb88847a3fb8dab22848cf6647.tar.bz2
Issue #26020: Fix evaluation order for set literals
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 8e396fd..451791c 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2580,14 +2580,16 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
TARGET(BUILD_SET) {
PyObject *set = PySet_New(NULL);
int err = 0;
+ int i;
if (set == NULL)
goto error;
- while (--oparg >= 0) {
- PyObject *item = POP();
+ for (i = oparg; i > 0; i--) {
+ PyObject *item = PEEK(i);
if (err == 0)
err = PySet_Add(set, item);
Py_DECREF(item);
}
+ STACKADJ(-oparg);
if (err != 0) {
Py_DECREF(set);
goto error;