[pypy-svn] r55721 - in pypy/dist/pypy/interpreter: . test

fijal at codespeak.net fijal at codespeak.net
Mon Jun 9 22:58:19 CEST 2008


Author: fijal
Date: Mon Jun  9 22:58:18 2008
New Revision: 55721

Modified:
   pypy/dist/pypy/interpreter/function.py
   pypy/dist/pypy/interpreter/test/test_function.py
Log:
Allow func.func_defaults = None


Modified: pypy/dist/pypy/interpreter/function.py
==============================================================================
--- pypy/dist/pypy/interpreter/function.py	(original)
+++ pypy/dist/pypy/interpreter/function.py	Mon Jun  9 22:58:18 2008
@@ -230,8 +230,11 @@
         return space.newtuple(values_w)
 
     def fset_func_defaults(space, self, w_defaults):
+        if space.is_w(w_defaults, space.w_None):
+            self.defs_w = []
+            return
         if not space.is_true( space.isinstance( w_defaults, space.w_tuple ) ):
-            raise OperationError( space.w_TypeError, space.wrap("func_defaults must be set to a tuple object") )
+            raise OperationError( space.w_TypeError, space.wrap("func_defaults must be set to a tuple object or None") )
         self.defs_w = space.unpackiterable( w_defaults )
 
     def fdel_func_defaults(space, self):

Modified: pypy/dist/pypy/interpreter/test/test_function.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_function.py	(original)
+++ pypy/dist/pypy/interpreter/test/test_function.py	Mon Jun  9 22:58:18 2008
@@ -11,6 +11,8 @@
         def f(): pass
         assert hasattr(f, 'func_code')
         assert f.func_defaults == None
+        f.func_defaults = None
+        assert f.func_defaults == None
         assert f.func_dict == {}
         assert type(f.func_globals) == dict
         #self.assertEquals(f.func_closure, None)  XXX



More information about the Pypy-commit mailing list