[Python-checkins] python/dist/src/Objects classobject.c, 2.175, 2.176 object.c, 2.222, 2.223 typeobject.c, 2.263, 2.264

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Thu Sep 23 04:39:39 CEST 2004


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3702/Objects

Modified Files:
	classobject.c object.c typeobject.c 
Log Message:
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[].


Index: classobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v
retrieving revision 2.175
retrieving revision 2.176
diff -u -d -r2.175 -r2.176
--- classobject.c	3 Aug 2004 10:21:03 -0000	2.175
+++ classobject.c	23 Sep 2004 02:39:36 -0000	2.176
@@ -1873,9 +1873,6 @@
 	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 *
 instance_richcompare(PyObject *v, PyObject *w, int op)
 {
@@ -1889,7 +1886,7 @@
 	}
 
 	if (PyInstance_Check(w)) {
-		res = half_richcompare(w, v, swapped_op[op]);
+		res = half_richcompare(w, v, _Py_SwappedOp[op]);
 		if (res != Py_NotImplemented)
 			return res;
 		Py_DECREF(res);

Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.222
retrieving revision 2.223
diff -u -d -r2.222 -r2.223
--- object.c	14 Sep 2004 17:09:47 -0000	2.222
+++ object.c	23 Sep 2004 02:39:37 -0000	2.223
@@ -476,7 +476,7 @@
                          ? (t)->tp_richcompare : NULL)
 
 /* 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:
    NULL for exception;
@@ -494,7 +494,7 @@
 	if (v->ob_type != w->ob_type &&
 	    PyType_IsSubtype(w->ob_type, v->ob_type) &&
 	    (f = RICHCOMPARE(w->ob_type)) != NULL) {
-		res = (*f)(w, v, swapped_op[op]);
+		res = (*f)(w, v, _Py_SwappedOp[op]);
 		if (res != Py_NotImplemented)
 			return res;
 		Py_DECREF(res);
@@ -506,7 +506,7 @@
 		Py_DECREF(res);
 	}
 	if ((f = RICHCOMPARE(w->ob_type)) != NULL) {
-		return (*f)(w, v, swapped_op[op]);
+		return (*f)(w, v, _Py_SwappedOp[op]);
 	}
 	res = Py_NotImplemented;
 	Py_INCREF(res);
@@ -1703,7 +1703,7 @@
 
 	assert(result);
 	if (!PyList_Check(result)) {
-		PyErr_SetString(PyExc_TypeError, 
+		PyErr_SetString(PyExc_TypeError,
 			"Expected keys() to be a list.");
 		goto error;
 	}

Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.263
retrieving revision 2.264
diff -u -d -r2.263 -r2.264
--- typeobject.c	18 Aug 2004 13:16:54 -0000	2.263
+++ typeobject.c	23 Sep 2004 02:39:37 -0000	2.264
@@ -4638,9 +4638,6 @@
 	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 *
 slot_tp_richcompare(PyObject *self, PyObject *other, int op)
 {
@@ -4653,7 +4650,7 @@
 		Py_DECREF(res);
 	}
 	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) {
 			return res;
 		}



More information about the Python-checkins mailing list