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 ronaldoussoren
Recipients ronaldoussoren
Date 2013-06-10.13:15:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1370870153.93.0.646087371852.issue18181@psf.upfronthosting.co.za>
In-reply-to
Content
Super() walks the MRO and looks for the looked-up attribute in the __dict__ of types on the MRO. This can cause problems when classes implement __getattribute__: a class on the MRO can implement a method that super() won't find because it isn't in the class __dict__ (yet).

I'm running into this with PyObjC: the __dict__ for the Python proxies for Objective-C classes are filled lazily (*) by tp_getattro (__getattribute__ in Python) to speed up the bridge and because ObjC is almost as dynamic as Python and methods might appear during runtime (without there being a hook for detecting such changes).

A possible solution to this:

* Add a tp_getattro_super (**) slot to PyTypeObject, with the 
  same signature as tp_getattro, but that only looks at this particular
  class (as opposed to tp_getattro that walks the entire MRO and looks
  in the object's __dict__)  (***)

* The tp_gettro of super calls tp_getattro_super of types of along the
  MRO when that slot is not NULL, and uses the current implementation
  (look in tp_dict) when the slot is NULL.

Would such a change be acceptable?

Open issues:

* Does the new slot get exposed to Python code 
  (and if so, under which name)?

* Should PyObject_GenericGetAttr use the new slot as well?


Footnotes:

(*) The current release of PyObjC (2.5) eagerly tries to keep the proxy class __dict__ up to date, an upcoming major release will be as lazy as possible to speed up the bridge. The problem can with some effert be triggered with PyObjC 2.5, and triggering it is easy in the upcoming major release

(**) Or some better name

(***) I'm being very sloppy in my use of terminology here, hopefully my proposal is clear enough anyway.
History
Date User Action Args
2013-06-10 13:15:53ronaldoussorensetrecipients: + ronaldoussoren
2013-06-10 13:15:53ronaldoussorensetmessageid: <1370870153.93.0.646087371852.issue18181@psf.upfronthosting.co.za>
2013-06-10 13:15:53ronaldoussorenlinkissue18181 messages
2013-06-10 13:15:53ronaldoussorencreate