]> granicus.if.org Git - python/commit
Redo the PyMethod attributes using a dir()-friendly approach, creating
authorGuido van Rossum <guido@python.org>
Tue, 18 Sep 2001 03:53:24 +0000 (03:53 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 18 Sep 2001 03:53:24 +0000 (03:53 +0000)
commitf0b35e1501f279aba1b97df068c6bc7384e2ab1a
treee1cf13b51b0275e6069e340eeaa02152b0eb5e75
parentbd131497112da319c4361c3e8656b5b7055011e3
Redo the PyMethod attributes using a dir()-friendly approach, creating
descriptors for each attribute.  The getattr() implementation is
similar to PyObject_GenericGetAttr(), but delegates to im_self instead
of looking in __dict__; I couldn't do this as a wrapper around
PyObject_GenericGetAttr().

XXX A problem here is that this is a case of *delegation*.  dir()
doesn't see exactly the same attributes that are actually defined;
e.g. if the delegate is a Python function object, it supports
attributes like func_code etc., but these are not visible to dir(); on
the other hand, dynamic function attributes (stored in the function's
__dict__) *are* visible to dir().  Maybe we need a mechanism to tell
dir() about the delegation mechanism?  I vaguely recall seeing a
request in the newsgroup for a more formal definition of attribute
delegation too.  Sigh, time for a new PEP.
Objects/classobject.c