diff 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
line wrap: on
line diff
--- a/Python/compile.c	Thu Mar 01 14:07:19 2007 +0000
+++ b/Python/compile.c	Fri Mar 02 19:19:05 2007 +0000
@@ -773,13 +773,17 @@
 				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