[Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.24,2.126.4.25

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Thu, 10 Oct 2002 17:22:24 -0700


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

Modified Files:
      Tag: release22-maint
	typeobject.c 
Log Message:
New in 2.2.2!

In inherit_slots(), get rid of the COPYSLOT(tp_dictoffset).  Copying
the offset from a non-dominant base makes no sense: either the
non-dominant base has a nonzero tp_dictoffset, and then we should have
already copied it from the dominant base (at the very end of
inherit_special()), or the non-dominant base has no tp_dictoffset and
for some reason type_new() decided not to add one.  The tp_dictoffset
from a non-dominant base is likely to conflict with the instance
layout of the dominant base, so copying the tp_dictoffset from the
non-dominant base would be a really bad idea in that case.  This bug
can only be triggered by multiple inheritance from an extension class
that doesn't set tp_dictoffset and a new-style user-level class that
does have one.  There are no such extension classes in the
distribution, but there are 3rd party ones.  (Zope3 now has one,
that's how I found this. :-)

I've asked a few heavy users of new-style classes, extension classes
and metaclasses (David Abrahams and Kevin Jacobs), and neither of them
found any problems in their test suite after applying this fix, so I
assume it's safe.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.126.4.24
retrieving revision 2.126.4.25
diff -C2 -d -r2.126.4.24 -r2.126.4.25
*** typeobject.c	7 Oct 2002 18:08:27 -0000	2.126.4.24
--- typeobject.c	11 Oct 2002 00:22:22 -0000	2.126.4.25
***************
*** 2088,2092 ****
  		COPYSLOT(tp_descr_get);
  		COPYSLOT(tp_descr_set);
- 		COPYSLOT(tp_dictoffset);
  		COPYSLOT(tp_init);
  		COPYSLOT(tp_alloc);
--- 2088,2091 ----