comparison Python/compile.c @ 40997:be68da561dcd 2.5

Fix constantification of None.
author Raymond Hettinger <python@rcn.com>
date Fri, 02 Mar 2007 19:19:05 +0000
parents 9acc1775d571
children fec1296544ab
comparison
equal deleted inserted replaced
40994:be44bf2db350 40997:be68da561dcd
771 j = GETARG(codestr, i); 771 j = GETARG(codestr, i);
772 name = PyString_AsString(PyTuple_GET_ITEM(names, j)); 772 name = PyString_AsString(PyTuple_GET_ITEM(names, j));
773 if (name == NULL || strcmp(name, "None") != 0) 773 if (name == NULL || strcmp(name, "None") != 0)
774 continue; 774 continue;
775 for (j=0 ; j < PyList_GET_SIZE(consts) ; j++) { 775 for (j=0 ; j < PyList_GET_SIZE(consts) ; j++) {
776 if (PyList_GET_ITEM(consts, j) == Py_None) { 776 if (PyList_GET_ITEM(consts, j) == Py_None)
777 codestr[i] = LOAD_CONST;
778 SETARG(codestr, i, j);
779 cumlc = lastlc + 1;
780 break; 777 break;
781 }
782 } 778 }
779 if (j == PyList_GET_SIZE(consts)) {
780 if (PyList_Append(consts, Py_None) == -1)
781 goto exitUnchanged;
782 }
783 assert(PyList_GET_ITEM(consts, j) == Py_None);
784 codestr[i] = LOAD_CONST;
785 SETARG(codestr, i, j);
786 cumlc = lastlc + 1;
783 break; 787 break;
784 788
785 /* Skip over LOAD_CONST trueconst 789 /* Skip over LOAD_CONST trueconst
786 JUMP_IF_FALSE xx POP_TOP */ 790 JUMP_IF_FALSE xx POP_TOP */
787 case LOAD_CONST: 791 case LOAD_CONST: