[pypy-svn] r29929 - in pypy/dist/pypy/objspace/std: . test

arigo at codespeak.net arigo at codespeak.net
Mon Jul 10 20:45:10 CEST 2006


Author: arigo
Date: Mon Jul 10 20:45:06 2006
New Revision: 29929

Modified:
   pypy/dist/pypy/objspace/std/test/test_typeobject.py
   pypy/dist/pypy/objspace/std/typeobject.py
Log:
Yet another fix for the 'type.__module__' descriptor.  A bit hackish.


Modified: pypy/dist/pypy/objspace/std/test/test_typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_typeobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_typeobject.py	Mon Jul 10 20:45:06 2006
@@ -483,3 +483,12 @@
         b = B("b")
         b.x = 3
         assert b.x == 3
+
+    def test_module(self):
+        assert object.__module__ == '__builtin__'
+        assert int.__module__ == '__builtin__'
+        assert type.__module__ == '__builtin__'
+        d = {'__name__': 'yay'}
+        exec """class A(object):\n  pass\n""" in d
+        A = d['A']
+        assert A.__module__ == 'yay'

Modified: pypy/dist/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typeobject.py	(original)
+++ pypy/dist/pypy/objspace/std/typeobject.py	Mon Jul 10 20:45:06 2006
@@ -315,7 +315,8 @@
 
     def get_module(w_self):
         space = w_self.space
-        if '__module__' in w_self.dict_w:
+        if (not space.is_w(w_self, space.w_type)    # hum
+            and '__module__' in w_self.dict_w):
             return w_self.dict_w['__module__']
         else:
             return space.wrap('__builtin__')



More information about the Pypy-commit mailing list