This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mwh
Recipients
Date 2005-04-03.14:32:16
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=6656

> I'm confused: the rule for negative slot offsets appear to be
> different to the one for tp_dictoffset

Yes.  I think this is actually necessary.

Consider:

class S(str):
    __slots__ = ['a']

you'd except S.__dict__['a'].__offset__ (well, if the attribute existed) to be 
-4.

Then

class T(S):
    __slots__ = ['b']

then using the 'from the end of the object' rule for  T().a would actually find 
T.b.  (IOW, T.__dict__['b'].__offset__ == T.__dict__['a'].__offset__ == -4).  
The alternative would be to somehow override all the slots in S when T is 
defined -- and this doesn't seem wise.

__dict__ indeed works differently, because 
instance.__class__.__dictoffset__ is updated on subclassing.  You could 
make __dict__ work like the slots mentioned above, but then you'd have to 
find the '__dict__' descriptor every time you wanted to access an 
instance's dictionary, and that would be slow (and might even not really 
work, but I don't want to risk brain-explosion by thinking about it too hard)

> which only increases the amount of obscurity around here.

Yeah, sorry about that.

I think something I've realised over the past few days is that __dict__ 
really is special.  I'm not sure __weakref__ is (though I guess it's special in 
that you want to be able to access it from C without any risk of executing 
Python level code, i.e. replacing Py_GETWEAKREFLIST(ob) with 
PyOjbect_GetAttrString(ob, "__weakref__") would be unfortunate).

> This should be resolved one way or the other 

See above -- don't think you can.

> -- and I think that
> a clear picture of the various parts of the object and how they
> are measured would be a good start.

No kidding here!

> That's also related to your proposed change to extra_ivars(),
> which would become slightly more permissive; I strongly suspect
> that it would allow more strange segfaulting cases to sneak in
> undetected...

Almost certainly!
History
Date User Action Args
2007-08-23 15:42:30adminlinkissue1173475 messages
2007-08-23 15:42:30admincreate