[Python-checkins] CVS: python/dist/src/Objects classobject.c,2.144,2.145
Guido van Rossum
gvanrossum@users.sourceforge.net
Fri, 07 Sep 2001 14:08:34 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv10850
Modified Files:
classobject.c
Log Message:
PyClass_New(): put the extended Don Beaudry hook back in. When one of
the base classes is not a classic class, and its class (the metaclass)
is callable, call the metaclass to do the deed.
One effect of this is that, when mixing classic and new-style classes
amongst the bases of a class, it doesn't matter whether the first base
class is a classic class or not: you will always get the error
"TypeError: metatype conflict among bases". (Formerly, with a classic
class first, you'd get "TypeError: PyClass_New: base must be a class".)
Another effect is that multiple inheritance from ExtensionClass.Base,
with a classic class as the first class, transfers control to the
ExtensionClass.Base class. This is what we need for SF #443239 (and
also for running Zope under 2.2a4, before ExtensionClass is replaced).
Index: classobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v
retrieving revision 2.144
retrieving revision 2.145
diff -C2 -d -r2.144 -r2.145
*** classobject.c 2001/09/05 22:52:50 2.144
--- classobject.c 2001/09/07 21:08:32 2.145
***************
*** 66,70 ****
}
else {
! int i;
if (!PyTuple_Check(bases)) {
PyErr_SetString(PyExc_TypeError,
--- 66,71 ----
}
else {
! int i, n;
! PyObject *base;
if (!PyTuple_Check(bases)) {
PyErr_SetString(PyExc_TypeError,
***************
*** 72,78 ****
return NULL;
}
! i = PyTuple_Size(bases);
! while (--i >= 0) {
! if (!PyClass_Check(PyTuple_GetItem(bases, i))) {
PyErr_SetString(PyExc_TypeError,
"PyClass_New: base must be a class");
--- 73,88 ----
return NULL;
}
! n = PyTuple_Size(bases);
! for (i = 0; i < n; i++) {
! base = PyTuple_GET_ITEM(bases, i);
! if (!PyClass_Check(base)) {
! if (PyCallable_Check(
! (PyObject *) base->ob_type))
! return PyObject_CallFunction(
! (PyObject *) base->ob_type,
! "OOO",
! name,
! bases,
! dict);
PyErr_SetString(PyExc_TypeError,
"PyClass_New: base must be a class");