Andreas Stührk <andy-pyt...@hammerhartes.de> added the comment: > 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 one. >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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11133> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com