]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport my checkin of revision 2.264 of Python/compile.c:
authorMichael W. Hudson <mwh@python.net>
Mon, 7 Oct 2002 11:30:07 +0000 (11:30 +0000)
committerMichael W. Hudson <mwh@python.net>
Mon, 7 Oct 2002 11:30:07 +0000 (11:30 +0000)
Clamp code objects' tp_compare result to [-1, 1].

Bugfix candidate.

Python/compile.c

index cdd8b1b3905b39fb8184657561051ee9fa3acd59..f3d9a20cf89fb817fdb961e9401575188cfbc31d 100644 (file)
@@ -133,11 +133,11 @@ code_compare(PyCodeObject *co, PyCodeObject *cp)
        cmp = PyObject_Compare(co->co_name, cp->co_name);
        if (cmp) return cmp;
        cmp = co->co_argcount - cp->co_argcount;
-       if (cmp) return cmp;
+       if (cmp) return (cmp<0)?-1:1;
        cmp = co->co_nlocals - cp->co_nlocals;
-       if (cmp) return cmp;
+       if (cmp) return (cmp<0)?-1:1;
        cmp = co->co_flags - cp->co_flags;
-       if (cmp) return cmp;
+       if (cmp) return (cmp<0)?-1:1;
        cmp = PyObject_Compare(co->co_code, cp->co_code);
        if (cmp) return cmp;
        cmp = PyObject_Compare(co->co_consts, cp->co_consts);