[Python-checkins] CVS: python/dist/src PLAN.txt,1.1.2.23,1.1.2.24
Tim Peters
tim_one@users.sourceforge.net
Sun, 08 Jul 2001 12:16:32 -0700
Update of /cvsroot/python/python/dist/src
In directory usw-pr-cvs1:/tmp/cvs-serv7970/descr/dist/src
Modified Files:
Tag: descr-branch
PLAN.txt
Log Message:
Add a "real" tp_new slot to dicts, in order to get dicts initialized
before use. I'm certain I didn't do it correctly, but don't understand
what "correctly" entails, exactly. See PLAN.txt for more details.
test_descr.py doesn't core dump anymore, but fails one line later with
a verify() failure.
Index: PLAN.txt
===================================================================
RCS file: /cvsroot/python/python/dist/src/Attic/PLAN.txt,v
retrieving revision 1.1.2.23
retrieving revision 1.1.2.24
diff -C2 -r1.1.2.23 -r1.1.2.24
*** PLAN.txt 2001/07/08 07:47:05 1.1.2.23
--- PLAN.txt 2001/07/08 19:16:30 1.1.2.24
***************
*** 268,272 ****
he dies of frustration while wrestling with CVS <0.9 wink>).
! ------------------------------------------------------------------
2001-07-07
--- 268,272 ----
he dies of frustration while wrestling with CVS <0.9 wink>).
! ----------------------------------------------------------------------------
2001-07-07
***************
*** 286,317 ****
correct exact order <wink>).
! Now dies with a memory error right after
! Testing Python subclass of dict...
! Small program that reproduces the problem:
! class C(dictionary):
! def __init__(self):
! self['a'] = 1
!
! a = C()
!
! Gross cause: The dictionary has not been initialized, i.e.
! mp->ma_table is NULL when we get into lookdict_string. But
! mp->ma_table must never be NULL after the trunk dict rewrite (any
! legit way of creating the dict will leave ma_table pointing to
! the ma_smalltable member).
!
! Note: We get into lookdict_string because insertdict forces
! mp->ma_lookup to lookdict_string if mp->ma_lookup is NULL. It
! is in this case. But that again says this object never went thru
! dict initialization: insertdict should really be asserting that
! mp->ma_lookup is not NULL on entry! The trunk version simply
! assumes it's not NULL (it's impossible to create a dict object
! with it NULL).
!
! Looks like Guido added this in descr-branch rev 2.80.2.6
! of dictobject.c; but this form of casting cheat doesn't work
! anymore on dicts.
! ------------------------------------------------------------------
2001-07-06
--- 286,317 ----
correct exact order <wink>).
! A core dump was "fixed" (unsure about that!) via adding a
! tp_new slot to dict objects, to ensure that they're initialized
! before being used.
!
! Now dies with
! File "../lib/test\test_descr.py", line 325, in pydicts
! verify(a1.state == 12)
! AttributeError: 'dictionary' object has no attribute 'state'
!
! I don't understand what tp_new is supposed to do for dicts,
! exactly. PEP 253 says
!
! - If the base type defines tp_init as well as tp_new, its tp_new
! should be inheritable: it should call the tp_alloc and the
! tp_init of the type passed in as its first argument.
!
! The tp_new I added doesn't do that, mostly because I couldn't find
! any code that already does that in order to fill in the fine
! points. PEP 253 also says tp_alloc has signature:
!
! PyObject *tp_alloc(PyTypeObject *type,
! PyObject *args,
! PyObject *kwds)
! but in reality it appears to be this instead:
!
! typedef PyObject *(*allocfunc)(struct _typeobject *, int);
! ----------------------------------------------------------------------------
2001-07-06