Commit dad2d088 authored by Tim Peters's avatar Tim Peters

A static swapped_op[] array was defined in 3 different C files, & I think

I need to define it again.  Bite the bullet and define it once as an
extern, _Py_SwappedOp[].
parent c9c57fb9
...@@ -667,6 +667,11 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */ ...@@ -667,6 +667,11 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
#define Py_GT 4 #define Py_GT 4
#define Py_GE 5 #define Py_GE 5
/* Maps Py_LT to Py_GT, ..., Py_GE to Py_LE.
* Defined in object.c.
*/
PyAPI_DATA(int) _Py_SwappedOp[];
/* /*
Define staticforward and statichere for source compatibility with old Define staticforward and statichere for source compatibility with old
C extensions. C extensions.
......
...@@ -1873,9 +1873,6 @@ half_richcompare(PyObject *v, PyObject *w, int op) ...@@ -1873,9 +1873,6 @@ half_richcompare(PyObject *v, PyObject *w, int op)
return res; return res;
} }
/* Map rich comparison operators to their swapped version, e.g. LT --> GT */
static int swapped_op[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE};
static PyObject * static PyObject *
instance_richcompare(PyObject *v, PyObject *w, int op) instance_richcompare(PyObject *v, PyObject *w, int op)
{ {
...@@ -1889,7 +1886,7 @@ instance_richcompare(PyObject *v, PyObject *w, int op) ...@@ -1889,7 +1886,7 @@ instance_richcompare(PyObject *v, PyObject *w, int op)
} }
if (PyInstance_Check(w)) { if (PyInstance_Check(w)) {
res = half_richcompare(w, v, swapped_op[op]); res = half_richcompare(w, v, _Py_SwappedOp[op]);
if (res != Py_NotImplemented) if (res != Py_NotImplemented)
return res; return res;
Py_DECREF(res); Py_DECREF(res);
......
...@@ -476,7 +476,7 @@ adjust_tp_compare(int c) ...@@ -476,7 +476,7 @@ adjust_tp_compare(int c)
? (t)->tp_richcompare : NULL) ? (t)->tp_richcompare : NULL)
/* Map rich comparison operators to their swapped version, e.g. LT --> GT */ /* Map rich comparison operators to their swapped version, e.g. LT --> GT */
static int swapped_op[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; extern int _Py_SwappedOp[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE};
/* Try a genuine rich comparison, returning an object. Return: /* Try a genuine rich comparison, returning an object. Return:
NULL for exception; NULL for exception;
...@@ -494,7 +494,7 @@ try_rich_compare(PyObject *v, PyObject *w, int op) ...@@ -494,7 +494,7 @@ try_rich_compare(PyObject *v, PyObject *w, int op)
if (v->ob_type != w->ob_type && if (v->ob_type != w->ob_type &&
PyType_IsSubtype(w->ob_type, v->ob_type) && PyType_IsSubtype(w->ob_type, v->ob_type) &&
(f = RICHCOMPARE(w->ob_type)) != NULL) { (f = RICHCOMPARE(w->ob_type)) != NULL) {
res = (*f)(w, v, swapped_op[op]); res = (*f)(w, v, _Py_SwappedOp[op]);
if (res != Py_NotImplemented) if (res != Py_NotImplemented)
return res; return res;
Py_DECREF(res); Py_DECREF(res);
...@@ -506,7 +506,7 @@ try_rich_compare(PyObject *v, PyObject *w, int op) ...@@ -506,7 +506,7 @@ try_rich_compare(PyObject *v, PyObject *w, int op)
Py_DECREF(res); Py_DECREF(res);
} }
if ((f = RICHCOMPARE(w->ob_type)) != NULL) { if ((f = RICHCOMPARE(w->ob_type)) != NULL) {
return (*f)(w, v, swapped_op[op]); return (*f)(w, v, _Py_SwappedOp[op]);
} }
res = Py_NotImplemented; res = Py_NotImplemented;
Py_INCREF(res); Py_INCREF(res);
......
...@@ -4638,9 +4638,6 @@ half_richcompare(PyObject *self, PyObject *other, int op) ...@@ -4638,9 +4638,6 @@ half_richcompare(PyObject *self, PyObject *other, int op)
return res; return res;
} }
/* Map rich comparison operators to their swapped version, e.g. LT --> GT */
static int swapped_op[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE};
static PyObject * static PyObject *
slot_tp_richcompare(PyObject *self, PyObject *other, int op) slot_tp_richcompare(PyObject *self, PyObject *other, int op)
{ {
...@@ -4653,7 +4650,7 @@ slot_tp_richcompare(PyObject *self, PyObject *other, int op) ...@@ -4653,7 +4650,7 @@ slot_tp_richcompare(PyObject *self, PyObject *other, int op)
Py_DECREF(res); Py_DECREF(res);
} }
if (other->ob_type->tp_richcompare == slot_tp_richcompare) { if (other->ob_type->tp_richcompare == slot_tp_richcompare) {
res = half_richcompare(other, self, swapped_op[op]); res = half_richcompare(other, self, _Py_SwappedOp[op]);
if (res != Py_NotImplemented) { if (res != Py_NotImplemented) {
return res; return res;
} }
......
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