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

arigo at codespeak.net arigo at codespeak.net
Fri Mar 4 15:09:02 CET 2005


Author: arigo
Date: Fri Mar  4 15:09:02 2005
New Revision: 9631

Modified:
   pypy/dist/pypy/interpreter/function.py
   pypy/dist/pypy/interpreter/test/test_function.py
Log:
The attribute f.__module__ was broken.  Added a test.



Modified: pypy/dist/pypy/interpreter/function.py
==============================================================================
--- pypy/dist/pypy/interpreter/function.py	(original)
+++ pypy/dist/pypy/interpreter/function.py	Fri Mar  4 15:09:02 2005
@@ -104,11 +104,11 @@
                 self.w_module = space.w_None
         return self.w_module
         
-    def fset___module__(space, w_self, w_module ):
+    def fset___module__(space, w_self, w_module):
         self = space.interpclass_w(w_self)
-        self.w_module = space.w_module
+        self.w_module = w_module
     
-    def fdel___module__(space, w_self, w_module ):
+    def fdel___module__(space, w_self):
         self = space.interpclass_w(w_self)
         self.w_module = space.w_None
 

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	Fri Mar  4 15:09:02 2005
@@ -8,6 +8,7 @@
 
 class AppTestFunctionIntrospection: 
     def test_attributes(self):
+        globals()['__name__'] = 'mymodulename'
         def f(): pass
         assert hasattr(f, 'func_code')
         assert f.func_defaults == None
@@ -16,6 +17,7 @@
         #self.assertEquals(f.func_closure, None)  XXX
         assert f.func_doc == None
         assert f.func_name == 'f'
+        assert f.__module__ == 'mymodulename'
 
     def test_code_is_ok(self):
         def f(): pass
@@ -46,6 +48,13 @@
         del f.func_doc
         assert f.func_doc == None
 
+    def test_write_module(self):
+        def f(): "hello"
+        f.__module__ = 'ab.c'
+        assert f.__module__ == 'ab.c'
+        del f.__module__
+        assert f.__module__ is None
+
 class AppTestFunction: 
     def test_simple_call(self):
         def func(arg1, arg2):



More information about the Pypy-commit mailing list