1. Armin Rigo
  2. cpython-withatomic

Commits

Michael W. Hudson  committed a94f272

Backport my checkin of revision 2.264 of Python/compile.c:

Clamp code objects' tp_compare result to [-1, 1].

Bugfix candidate.

  • Participants
  • Parent commits 8553927
  • Branches 2.2

Comments (0)

Files changed (1)

File Python/compile.c

View file
  • Ignore whitespace
 	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);