[pypy-svn] r68704 - in pypy/trunk/pypy/interpreter: . test

arigo at codespeak.net arigo at codespeak.net
Wed Oct 21 21:56:46 CEST 2009


Author: arigo
Date: Wed Oct 21 21:56:43 2009
New Revision: 68704

Modified:
   pypy/trunk/pypy/interpreter/function.py
   pypy/trunk/pypy/interpreter/test/test_function.py
Log:
issue475 resolved

Test and minimal fix.


Modified: pypy/trunk/pypy/interpreter/function.py
==============================================================================
--- pypy/trunk/pypy/interpreter/function.py	(original)
+++ pypy/trunk/pypy/interpreter/function.py	Wed Oct 21 21:56:43 2009
@@ -309,7 +309,7 @@
 
     def fget_func_defaults(space, self):
         values_w = self.defs_w
-        if not values_w:
+        if not values_w or None in values_w:
             return space.w_None
         return space.newtuple(values_w)
 

Modified: pypy/trunk/pypy/interpreter/test/test_function.py
==============================================================================
--- pypy/trunk/pypy/interpreter/test/test_function.py	(original)
+++ pypy/trunk/pypy/interpreter/test/test_function.py	Wed Oct 21 21:56:43 2009
@@ -644,3 +644,15 @@
 
         assert space.eq_w(w_res, space.wrap(44))
 
+
+class TestFunction:
+
+    def test_func_defaults(self):
+        from pypy.interpreter import gateway
+        def g(w_a=gateway.NoneNotWrapped):
+            pass
+        app_g = gateway.interp2app_temp(g)
+        space = self.space
+        w_g = space.wrap(app_g)
+        w_defs = space.getattr(w_g, space.wrap("func_defaults"))
+        assert space.is_w(w_defs, space.w_None)



More information about the Pypy-commit mailing list