Author Trundle
Recipients Trundle, daniel.urban, michael.foord, segfaulthunter
Date 2011-02-22.01:40:40
SpamBayes Score 5.58942e-08
Marked as misclassified No
Message-id <>
In-reply-to <>
> The patch is not sufficient - instances may have a class member "__dict__" whilst still having an instance __dict__.

Sure, but I don't think there is a way how you can access the instance
__dict__ in that case inside Python code. At least I can't think of

>Alternatively the "__dict__" property may be provided by a base class and so not available in "type(obj).__dict__" but still be provided by a property.
> I don't think there is any general way to tell whether fetching obj.__dict__ will get an instance dictionary or fetch a "__dict__" member from the class or a base-class... (Hence the documented exception.)

Why not? ``obj.__dict__`` will fetch the instance dictionary iff there
is no class attribute "__dict__" in any of the base classes. In the
patch,``type.__dict__["__dict__"].__get__()`` is used to get (without
any doubt) the class dictionary. By looking inside that dictionary, we
can now tell whether "__dict__" is overwritten: If it isn't
overwritten, the dictionary either doesn't have a "__dict__" entry at
all or the value is a getset_descriptor. So we just need to iterate
over a type's mro, look inside each entries' dictionary and stop when
a "__dict__" entry is found.
Date User Action Args
2011-02-22 01:40:41Trundlesetrecipients: + Trundle, segfaulthunter, michael.foord, daniel.urban
2011-02-22 01:40:40Trundlelinkissue11133 messages
2011-02-22 01:40:40Trundlecreate