diff Python/compile.c @ 12333:525b2358721e legacy-trunk

Patch by Vladimir Marangozov to include the function name when comparing code objects. This give sless surprising results in -Optimized code. It also sorts code objects by name, now. [I changed the patch to hash() slightly to touch fewer lines.]
author Guido van Rossum <guido@python.org>
date Mon, 10 Apr 2000 16:20:31 +0000
parents 647bf71912f0
children c48172af13dc
line wrap: on
line diff
--- a/Python/compile.c	Mon Apr 10 15:36:39 2000 +0000
+++ b/Python/compile.c	Mon Apr 10 16:20:31 2000 +0000
@@ -140,6 +140,8 @@
 	PyCodeObject *co, *cp;
 {
 	int cmp;
+	cmp = PyObject_Compare(co->co_name, cp->co_name);
+	if (cmp) return cmp;
 	cmp = co->co_argcount - cp->co_argcount;
 	if (cmp) return cmp;
 	cmp = co->co_nlocals - cp->co_nlocals;
@@ -160,7 +162,9 @@
 code_hash(co)
 	PyCodeObject *co;
 {
-	long h, h1, h2, h3, h4;
+	long h, h0, h1, h2, h3, h4;
+	h0 = PyObject_Hash(co->co_name);
+	if (h0 == -1) return -1;
 	h1 = PyObject_Hash(co->co_code);
 	if (h1 == -1) return -1;
 	h2 = PyObject_Hash(co->co_consts);
@@ -169,7 +173,7 @@
 	if (h3 == -1) return -1;
 	h4 = PyObject_Hash(co->co_varnames);
 	if (h4 == -1) return -1;
-	h = h1 ^ h2 ^ h3 ^ h4 ^
+	h = h0 ^ h1 ^ h2 ^ h3 ^ h4 ^
 		co->co_argcount ^ co->co_nlocals ^ co->co_flags;
 	if (h == -1) h = -2;
 	return h;