[pypy-svn] r59543 - in pypy/trunk/pypy/module/__builtin__: . test

arigo at codespeak.net arigo at codespeak.net
Thu Oct 30 12:38:02 CET 2008


Author: arigo
Date: Thu Oct 30 12:38:00 2008
New Revision: 59543

Modified:
   pypy/trunk/pypy/module/__builtin__/descriptor.py
   pypy/trunk/pypy/module/__builtin__/test/test_descriptor.py
Log:
Test and fix for a new 2.5 feature.


Modified: pypy/trunk/pypy/module/__builtin__/descriptor.py
==============================================================================
--- pypy/trunk/pypy/module/__builtin__/descriptor.py	(original)
+++ pypy/trunk/pypy/module/__builtin__/descriptor.py	Thu Oct 30 12:38:00 2008
@@ -101,6 +101,11 @@
         self.w_fset = w_fset
         self.w_fdel = w_fdel
         self.w_doc = w_doc
+        # our __doc__ comes from the getter if we don't have an explicit one
+        if space.is_w(self.w_doc, space.w_None):
+            w_getter_doc = space.findattr(self.w_fget, space.wrap("__doc__"))
+            if w_getter_doc is not None:
+                self.w_doc = w_getter_doc
 
     def new(space, w_subtype, w_fget=None, w_fset=None, w_fdel=None, w_doc=None):
         w_result = space.allocate_instance(W_Property, w_subtype)

Modified: pypy/trunk/pypy/module/__builtin__/test/test_descriptor.py
==============================================================================
--- pypy/trunk/pypy/module/__builtin__/test/test_descriptor.py	(original)
+++ pypy/trunk/pypy/module/__builtin__/test/test_descriptor.py	Thu Oct 30 12:38:00 2008
@@ -237,6 +237,11 @@
         A.x = property(lambda x: x, lambda x, y: x, lambda x:x, 'xxx')
         assert A.x.__doc__ == 'xxx'
 
+        # new in 2.5:
+        def foo(x):
+            "my docstring"
+        assert property(foo).__doc__ == "my docstring"
+
     def test_property(self):
         class C(object):
             def getx(self):



More information about the Pypy-commit mailing list