diff options
Diffstat (limited to 'Modules/_tkinter.c')
-rw-r--r-- | Modules/_tkinter.c | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 005214e..7123da5 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -864,13 +864,10 @@ PyTclObject_repr(PyTclObject *self) return repr; } -#define TEST_COND(cond) ((cond) ? Py_True : Py_False) - static PyObject * PyTclObject_richcompare(PyObject *self, PyObject *other, int op) { int result; - PyObject *v; /* neither argument should be NULL, unless something's gone wrong */ if (self == NULL || other == NULL) { @@ -880,8 +877,7 @@ PyTclObject_richcompare(PyObject *self, PyObject *other, int op) /* both arguments should be instances of PyTclObject */ if (!PyTclObject_Check(self) || !PyTclObject_Check(other)) { - v = Py_NotImplemented; - goto finished; + Py_RETURN_NOTIMPLEMENTED; } if (self == other) @@ -890,33 +886,7 @@ PyTclObject_richcompare(PyObject *self, PyObject *other, int op) else result = strcmp(Tcl_GetString(((PyTclObject *)self)->value), Tcl_GetString(((PyTclObject *)other)->value)); - /* Convert return value to a Boolean */ - switch (op) { - case Py_EQ: - v = TEST_COND(result == 0); - break; - case Py_NE: - v = TEST_COND(result != 0); - break; - case Py_LE: - v = TEST_COND(result <= 0); - break; - case Py_GE: - v = TEST_COND(result >= 0); - break; - case Py_LT: - v = TEST_COND(result < 0); - break; - case Py_GT: - v = TEST_COND(result > 0); - break; - default: - PyErr_BadArgument(); - return NULL; - } - finished: - Py_INCREF(v); - return v; + Py_RETURN_RICHCOMPARE(result, 0, op); } PyDoc_STRVAR(get_typename__doc__, "name of the Tcl type"); |