summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2000-08-18 04:57:32 (GMT)
committerBarry Warsaw <barry@python.org>2000-08-18 04:57:32 (GMT)
commitdc55d715bbe23ccda3942da667211ff796f31ed2 (patch)
treefb5d70f461292fd3cb0e323eaea4cd8c26df61f3
parentbc7c7f991c4654cb270cc09272559534de492d30 (diff)
downloadcpython-dc55d715bbe23ccda3942da667211ff796f31ed2.zip
cpython-dc55d715bbe23ccda3942da667211ff796f31ed2.tar.gz
cpython-dc55d715bbe23ccda3942da667211ff796f31ed2.tar.bz2
PyInstance_DoBinOp(): When comparing the pointers, they must be cast
to integer types (i.e. Py_uintptr_t, our spelling of C9X's uintptr_t). ANSI specifies that pointer compares other than == and != to non-related structures are undefined. This quiets an Insure portability warning.
-rw-r--r--Objects/classobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 66d1080..f0f4438 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -1207,13 +1207,16 @@ PyInstance_DoBinOp(PyObject *v, PyObject *w, char *opname, char *ropname,
{
char buf[256];
PyObject *result = NULL;
+
if (halfbinop(v, w, opname, &result, thisfunc, 0) <= 0)
return result;
if (halfbinop(w, v, ropname, &result, thisfunc, 1) <= 0)
return result;
/* Sigh -- special case for comparisons */
if (strcmp(opname, "__cmp__") == 0) {
- long c = (v < w) ? -1 : (v > w) ? 1 : 0;
+ Py_uintptr_t iv = (Py_uintptr_t)v;
+ Py_uintptr_t iw = (Py_uintptr_t)w;
+ long c = (iv < iw) ? -1 : (iv > iw) ? 1 : 0;
return PyInt_FromLong(c);
}
sprintf(buf, "%s nor %s defined for these operands", opname, ropname);