[pypy-svn] r5555 - in pypy/trunk/src/pypy/interpreter: . test
mwh at codespeak.net
mwh at codespeak.net
Wed Jul 14 14:27:03 CEST 2004
Author: mwh
Date: Wed Jul 14 14:27:03 2004
New Revision: 5555
Modified:
pypy/trunk/src/pypy/interpreter/function.py
pypy/trunk/src/pypy/interpreter/test/test_class.py
pypy/trunk/src/pypy/interpreter/typedef.py
Log:
fix the fact that methods had no __doc__
i think this is the Right Way to do it, if not, advice appreciated!
Modified: pypy/trunk/src/pypy/interpreter/function.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/function.py (original)
+++ pypy/trunk/src/pypy/interpreter/function.py Wed Jul 14 14:27:03 2004
@@ -115,6 +115,12 @@
def descr_method_call(self, __args__):
return self.call_args(__args__)
+ def descr_method_getattribute(self, w_attr):
+ space = self.space
+ w_result = space.lookup(space.wrap(self), w_attr)
+ if w_result is None:
+ return space.getattr(self.w_function, w_attr)
+
class StaticMethod(Wrappable):
"""A static method. Note that there is one class staticmethod at
app-level too currently; this is only used for __new__ methods."""
Modified: pypy/trunk/src/pypy/interpreter/test/test_class.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/test/test_class.py (original)
+++ pypy/trunk/src/pypy/interpreter/test/test_class.py Wed Jul 14 14:27:03 2004
@@ -113,5 +113,18 @@
self.assertEquals(type(float(x)), float)
self.assertEquals(float(x), 5.5)
+ def test_meth_doc(self):
+ class C:
+ def meth_no_doc(self):
+ pass
+ def meth_doc(self):
+ """this is a docstring"""
+ pass
+ c = C()
+ self.assertEquals(C.meth_no_doc.__doc__, None)
+ self.assertEquals(c.meth_no_doc.__doc__, None)
+ self.assertEquals(C.meth_doc.__doc__, """this is a docstring""")
+ self.assertEquals(c.meth_doc.__doc__, """this is a docstring""")
+
if __name__ == '__main__':
testit.main()
Modified: pypy/trunk/src/pypy/interpreter/typedef.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/typedef.py (original)
+++ pypy/trunk/src/pypy/interpreter/typedef.py Wed Jul 14 14:27:03 2004
@@ -237,6 +237,7 @@
im_func = attrproperty_w('w_function'),
im_self = attrproperty_w('w_instance'),
im_class = attrproperty_w('w_class'),
+ __getattribute__ = interp2app(Method.descr_method_getattribute.im_func),
# XXX getattribute/setattribute etc.pp
)
More information about the Pypy-commit
mailing list