diff options
author | Raymond Hettinger <python@rcn.com> | 2007-03-02 19:20:46 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-03-02 19:20:46 (GMT) |
commit | 20e1199fbe8493796a12d1c20ee1c857527fe396 (patch) | |
tree | 15f6cb86c5d952f2b69e0bad1a1d7e8660fa8a61 /Python | |
parent | 117a05ed502dc292a2e8ee5ff8c4cded55af1c61 (diff) | |
download | cpython-20e1199fbe8493796a12d1c20ee1c857527fe396.zip cpython-20e1199fbe8493796a12d1c20ee1c857527fe396.tar.gz cpython-20e1199fbe8493796a12d1c20ee1c857527fe396.tar.bz2 |
Fix embarrassing typo and fix constantification of None
Diffstat (limited to 'Python')
-rw-r--r-- | Python/peephole.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Python/peephole.c b/Python/peephole.c index f2fe6ce..7111331 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -1,4 +1,4 @@ -/* Peehole optimizations for bytecode compiler. */ +/* Peephole optimizations for bytecode compiler. */ #include "Python.h" @@ -386,13 +386,17 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, if (name == NULL || strcmp(name, "None") != 0) continue; for (j=0 ; j < PyList_GET_SIZE(consts) ; j++) { - if (PyList_GET_ITEM(consts, j) == Py_None) { - codestr[i] = LOAD_CONST; - SETARG(codestr, i, j); - cumlc = lastlc + 1; + if (PyList_GET_ITEM(consts, j) == Py_None) break; - } } + if (j == PyList_GET_SIZE(consts)) { + if (PyList_Append(consts, Py_None) == -1) + goto exitUnchanged; + } + assert(PyList_GET_ITEM(consts, j) == Py_None); + codestr[i] = LOAD_CONST; + SETARG(codestr, i, j); + cumlc = lastlc + 1; break; /* Skip over LOAD_CONST trueconst |