summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-10-03 09:50:47 (GMT)
committerMichael W. Hudson <mwh@python.net>2002-10-03 09:50:47 (GMT)
commit3ae3315f44c5a6f462844e51c830593f007ef881 (patch)
treedaef5c3ff3732769ee13ff00fa6c5776068c391a /Python
parentadf160616184c94ded19e99ccf5337a20d73d907 (diff)
downloadcpython-3ae3315f44c5a6f462844e51c830593f007ef881.zip
cpython-3ae3315f44c5a6f462844e51c830593f007ef881.tar.gz
cpython-3ae3315f44c5a6f462844e51c830593f007ef881.tar.bz2
Clamp code objects' tp_compare result to [-1, 1].
Bugfix candidate.
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 26c56f4..d916751 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -196,11 +196,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);