Skip to content

Commit 51e80df

Browse files
author
Michael W. Hudson
committed
Backport my checkin of revision 2.264 of Python/compile.c:
Clamp code objects' tp_compare result to [-1, 1]. Bugfix candidate.
1 parent c01f360 commit 51e80df

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎Python/compile.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ code_compare(PyCodeObject *co, PyCodeObject *cp)
133133
cmp = PyObject_Compare(co->co_name, cp->co_name);
134134
if (cmp) return cmp;
135135
cmp = co->co_argcount - cp->co_argcount;
136-
if (cmp) return cmp;
136+
if (cmp) return (cmp<0)?-1:1;
137137
cmp = co->co_nlocals - cp->co_nlocals;
138-
if (cmp) return cmp;
138+
if (cmp) return (cmp<0)?-1:1;
139139
cmp = co->co_flags - cp->co_flags;
140-
if (cmp) return cmp;
140+
if (cmp) return (cmp<0)?-1:1;
141141
cmp = PyObject_Compare(co->co_code, cp->co_code);
142142
if (cmp) return cmp;
143143
cmp = PyObject_Compare(co->co_consts, cp->co_consts);

0 commit comments

Comments
 (0)