Hello, Campbell Barton wrote: > Hey there, Recently I started to write a new python/C api for > Blender3D with python3.0rc3. > This PyApi is a thin wrapper for an autogenerated C API to be used by > the UI and animation system (all in C). > > Without going into too many details, Im using tp_getattr so the > requested attribute can be forwarded to our internal functions. > The Blender3D game engine that has used this method to wrap internal > data for some years as well, so I don't think this is that unusual. > > We moved most of our api's to use tp_getset, but that only works when > the attributes you need dont change. > > Quote... > http://mail.python.org/pipermail/python-3000/2008-July/014303.html >> The primary use of Py_FindMethod was to implement a tp_getattr slot >> handler. Now that it has been removed, there is nothing remaining in >> the py3k codebase that actually uses the tp_getattr slot! > >> It has been 12 years since tp_getattro was introduced. Is it time to >> finally phase out tp_getattr? > > I have no problems with breaking compatibility for python3000, however > in this case removal of Py_FindMethod, removes functionality for > external C api's that rely on dynamic attributes with tp_getattr. > > Is the intention to remove support for tp_getattr altogether? > > Note - in the meantime Ill add our own version of Py_FindMethod but > its not ideal.
The same functionality can be achieved with the tp_getattro slot: implement your special dynamic attributes there, and then call PyObject_GenericGetAttr for the default behavior. You may have a look at the implementation of the pyexpat module: Modules/pyexpat.c, function xmlparse_getattro -- Amaury Forgeot d'Arc _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com