Commit 8ed9a76f authored by Tim Peters's avatar Tim Peters

subclass_compare(): As reported by Neil Schemenauer, instances of

an ExtensionClass type that get into this code can raise RuntimeWarning
under Python 2.3, because the comparison result may be outside the
set {-1, 0, 1}.  Worse, on a box where sizeof(ptrdiff_t) > sizeof(int)
(all 64-bit platforms), comparison results across a set of objects
could be inconsistent because the implicit cast of pointer subtraction
to int loses the information-carrying sign bit.
parent 1d5e4c4f
...@@ -21,7 +21,7 @@ static char ExtensionClass_module_documentation[] = ...@@ -21,7 +21,7 @@ static char ExtensionClass_module_documentation[] =
" - They provide access to unbound methods,\n" " - They provide access to unbound methods,\n"
" - They can be called to create instances.\n" " - They can be called to create instances.\n"
"\n" "\n"
"$Id: ExtensionClass.c,v 1.59 2003/07/28 02:12:23 kiko Exp $\n" "$Id: ExtensionClass.c,v 1.60 2003/08/15 17:27:58 tim_one Exp $\n"
; ;
#include "ExtensionClass.h" #include "ExtensionClass.h"
...@@ -2299,7 +2299,7 @@ subclass_compare(PyObject *self, PyObject *v) ...@@ -2299,7 +2299,7 @@ subclass_compare(PyObject *self, PyObject *v)
UNLESS(m=subclass_getspecial(self,py__cmp__)) UNLESS(m=subclass_getspecial(self,py__cmp__))
{ {
PyErr_Clear(); PyErr_Clear();
return self-v; return self < v ? -1 : (self != v);
} }
if (UnboundCMethod_Check(m) if (UnboundCMethod_Check(m)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment