diff Objects/object.c @ 39222:b0cdcbcc5f45

Get rid of most of the flags (in tp_flags) that keep track of various variations of the type struct and its attachments. In Py3k, all type structs have to have all fields -- no binary backwards compatibility. Had to change the complex object to a new-style number!
author Guido van Rossum <guido@python.org>
date Thu, 27 Jul 2006 21:53:35 +0000
parents 19fd6141940d
children 654c380cf8b9
line wrap: on
line diff
--- a/Objects/object.c	Thu Jun 08 15:35:45 2006 +0000
+++ b/Objects/object.c	Thu Jul 27 21:53:35 2006 +0000
@@ -546,8 +546,7 @@
 
 
 /* Macro to get the tp_richcompare field of a type if defined */
-#define RICHCOMPARE(t) (PyType_HasFeature((t), Py_TPFLAGS_HAVE_RICHCOMPARE) \
-                         ? (t)->tp_richcompare : NULL)
+#define RICHCOMPARE(t) ((t)->tp_richcompare)
 
 /* Map rich comparison operators to their swapped version, e.g. LT --> GT */
 int _Py_SwappedOp[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE};
@@ -1224,8 +1223,6 @@
 	Py_ssize_t dictoffset;
 	PyTypeObject *tp = obj->ob_type;
 
-	if (!(tp->tp_flags & Py_TPFLAGS_HAVE_CLASS))
-		return NULL;
 	dictoffset = tp->tp_dictoffset;
 	if (dictoffset == 0)
 		return NULL;
@@ -1318,8 +1315,7 @@
 	Py_XINCREF(descr);
 
 	f = NULL;
-	if (descr != NULL &&
-	    PyType_HasFeature(descr->ob_type, Py_TPFLAGS_HAVE_CLASS)) {
+	if (descr != NULL) {
 		f = descr->ob_type->tp_descr_get;
 		if (f != NULL && PyDescr_IsData(descr)) {
 			res = f(descr, obj, (PyObject *)obj->ob_type);
@@ -1414,8 +1410,7 @@
 
 	descr = _PyType_Lookup(tp, name);
 	f = NULL;
-	if (descr != NULL &&
-	    PyType_HasFeature(descr->ob_type, Py_TPFLAGS_HAVE_CLASS)) {
+	if (descr != NULL) {
 		f = descr->ob_type->tp_descr_set;
 		if (f != NULL && PyDescr_IsData(descr)) {
 			res = f(descr, obj, value);
@@ -1518,14 +1513,6 @@
 	register PyObject *w = *pw;
 	int res;
 
-	/* Shortcut only for old-style types */
-	if (v->ob_type == w->ob_type &&
-	    !PyType_HasFeature(v->ob_type, Py_TPFLAGS_CHECKTYPES))
-	{
-		Py_INCREF(v);
-		Py_INCREF(w);
-		return 0;
-	}
 	if (v->ob_type->tp_as_number && v->ob_type->tp_as_number->nb_coerce) {
 		res = (*v->ob_type->tp_as_number->nb_coerce)(pv, pw);
 		if (res <= 0)