From 0161aabf5def310ce8ec332842f68cbce099480d Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 13 Oct 2006 21:14:15 +0000 Subject: [PATCH] constrain tp_compare() to return -1, 0, or 1 --- dtool/src/interrogatedb/py_panda.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index c31a2d64dc..e5e6ac8f72 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -490,7 +490,15 @@ int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2) { int answer = PyInt_AsLong(res); Py_DECREF(res); - return answer; + + // Python really wants us to return strictly -1, 0, or 1. + if (answer < 0) { + return -1; + } else if (answer > 0) { + return 1; + } else { + return 0; + } } if(res != NULL) Py_DECREF(res);