| commit | e62a694fee53ba7fc16d6afbaa53b373c878f300 | [log] [tgz] |
|---|---|---|
| author | Raymond Hettinger <[email protected]> | Thu Sep 08 15:25:19 2016 -0700 |
| committer | Raymond Hettinger <[email protected]> | Thu Sep 08 15:25:19 2016 -0700 |
| tree | 08464fc231f3efbe4328ab147ea9313df73cbfc5 | |
| parent | cb20a2174053148ba22d4d50a86bcef430c1b66f [diff] [blame] |
Issue #26020: Fix evaluation order for set literals
diff --git a/Python/ceval.c b/Python/ceval.c index 0b747d8..2af78ff 100644 --- a/Python/ceval.c +++ b/Python/ceval.c
@@ -2477,14 +2477,16 @@ TARGET(BUILD_SET) { + int i; x = PySet_New(NULL); if (x != NULL) { - for (; --oparg >= 0;) { - w = POP(); + for (i = oparg; i > 0; i--) { + w = PEEK(i); if (err == 0) err = PySet_Add(x, w); Py_DECREF(w); } + STACKADJ(-oparg); if (err != 0) { Py_DECREF(x); break;