[Python-checkins] CVS: python/dist/src/Include object.h,2.79.2.21,2.79.2.22

Guido van Rossum gvanrossum@users.sourceforge.net
Mon, 02 Jul 2001 17:37:49 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv15305/Include

Modified Files:
      Tag: descr-branch
	object.h 
Log Message:
Fix the subtype test (the previous checkins broke test_descr.py
because the subtype test was being applied in a multiple-inheritance
situation).

First, _PyObject_TypeCheck() is renamed to PyType_IsSubtype() and
moved from object.c to typeobject.c, where it belings.

Next, its implementation is changed to use the MRO tuple if it exists;

for bootstrap reasons, it walks the tp_base chain (single inheritance
only) as a fallback.

Finally, issubtype() is deleted and calls to it are replaced with a
call to PyType_IsSubtype().



Index: object.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/object.h,v
retrieving revision 2.79.2.21
retrieving revision 2.79.2.22
diff -C2 -r2.79.2.21 -r2.79.2.22
*** object.h	2001/07/02 17:08:33	2.79.2.21
--- object.h	2001/07/03 00:37:47	2.79.2.22
***************
*** 290,296 ****
  
  /* Generic type check */
! extern DL_IMPORT(int) _PyObject_TypeCheck(PyTypeObject *, PyTypeObject *);
  #define PyObject_TypeCheck(ob, tp) \
! 	((ob)->ob_type == (tp) || _PyObject_TypeCheck((ob)->ob_type, (tp)))
  
  extern DL_IMPORT(PyTypeObject) PyType_Type; /* Metatype */
--- 290,296 ----
  
  /* Generic type check */
! extern DL_IMPORT(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
  #define PyObject_TypeCheck(ob, tp) \
! 	((ob)->ob_type == (tp) || PyType_IsSubtype((ob)->ob_type, (tp)))
  
  extern DL_IMPORT(PyTypeObject) PyType_Type; /* Metatype */