summaryrefslogtreecommitdiff
path: root/Python/compile.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-03-02 19:19:05 +0000
committerRaymond Hettinger <python@rcn.com>2007-03-02 19:19:05 +0000
commitd882e36f459e20a3fb3f92aa57df3228d832f4e2 (patch)
tree167c81ed6ae322d70c72e5e9e0567e9437093f12 /Python/compile.c
parent8bc8ab5fec6ae5f6e7a5aa467933a3be55102c68 (diff)
downloadcpython-git-d882e36f459e20a3fb3f92aa57df3228d832f4e2.tar.gz
Fix constantification of None.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 8be3d79be9..e493beb6c2 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -773,13 +773,17 @@ optimize_code(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