[pypy-svn] r11787 - pypy/dist/pypy/interpreter

pedronis at codespeak.net pedronis at codespeak.net
Mon May 2 16:47:35 CEST 2005


Author: pedronis
Date: Mon May  2 16:47:35 2005
New Revision: 11787

Modified:
   pypy/dist/pypy/interpreter/module.py
   pypy/dist/pypy/interpreter/typedef.py
Log:
changes to pass test_module



Modified: pypy/dist/pypy/interpreter/module.py
==============================================================================
--- pypy/dist/pypy/interpreter/module.py	(original)
+++ pypy/dist/pypy/interpreter/module.py	Mon May  2 16:47:35 2005
@@ -12,9 +12,11 @@
         self.space = space
         if w_dict is None: 
             w_dict = space.newdict([])
+        elif space.is_w(w_dict, space.w_None):
+            w_dict = None
         self.w_dict = w_dict 
         self.w_name = w_name 
-        if w_name is not None:
+        if w_name is not None and w_dict is not None:
             space.setitem(w_dict, space.wrap('__name__'), w_name) 
 
     def getdict(self):
@@ -22,7 +24,7 @@
 
     def descr_module__new__(space, w_subtype, __args__):
         module = space.allocate_instance(Module, w_subtype)
-        Module.__init__(module, space, space.wrap('?'))
+        Module.__init__(module, space, space.wrap('?'), space.w_None)
         return space.wrap(module)
 
     def descr_module__init__(self, w_name, w_doc=None):
@@ -31,5 +33,7 @@
         if w_doc is None:  
             w_doc = space.w_None
         w_dict = self.getdict()
+        if w_dict is None:
+            w_dict = self.w_dict = space.newdict([])
         space.setitem(w_dict, space.wrap('__name__'), w_name)
         space.setitem(w_dict, space.wrap('__doc__'), w_doc)

Modified: pypy/dist/pypy/interpreter/typedef.py
==============================================================================
--- pypy/dist/pypy/interpreter/typedef.py	(original)
+++ pypy/dist/pypy/interpreter/typedef.py	Mon May  2 16:47:35 2005
@@ -280,6 +280,12 @@
     assert w_dict is not None, repr(obj)
     return w_dict
 
+def descr_get_dict_may_be_None(space, obj):
+    w_dict = obj.getdict()
+    if w_dict is None:
+        return space.w_None
+    return w_dict
+
 def descr_set_dict(space, obj, w_dict):
     obj.setdict(w_dict)
 
@@ -359,7 +365,8 @@
     __new__ = interp2app(Module.descr_module__new__.im_func,
                          unwrap_spec=[ObjSpace, W_Root, Arguments]),
     __init__ = interp2app(Module.descr_module__init__),
-    __dict__ = GetSetProperty(descr_get_dict, cls=Module), # module dictionaries are readonly attributes
+    __dict__ = GetSetProperty(descr_get_dict_may_be_None, cls=Module), # module dictionaries are readonly attributes
+    __doc__ = 'module(name[, doc])\n\nCreate a module object.\nThe name must be a string; the optional doc argument can have any type.'
     )
 
 getset_func_doc = GetSetProperty(Function.fget_func_doc,



More information about the Pypy-commit mailing list