mirror of
https://github.com/python/cpython.git
synced 2026-01-29 02:32:18 +00:00
Fix constantification of None.
This commit is contained in:
parent
8bc8ab5fec
commit
d882e36f45
3 changed files with 17 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue