[pypy-svn] r11860 - in pypy/dist/pypy: lib module/builtin

pedronis at codespeak.net pedronis at codespeak.net
Tue May 3 15:17:42 CEST 2005


Author: pedronis
Date: Tue May  3 15:17:42 2005
New Revision: 11860

Modified:
   pypy/dist/pypy/lib/imp.py
   pypy/dist/pypy/module/builtin/importing.py
Log:
fixes to pass test_pkg; load_module should overwrite the prev mod.__dict__ contents; import star logic should possibly use __all__
as fromlist for a package



Modified: pypy/dist/pypy/lib/imp.py
==============================================================================
--- pypy/dist/pypy/lib/imp.py	(original)
+++ pypy/dist/pypy/lib/imp.py	Tue May  3 15:17:42 2005
@@ -51,7 +51,6 @@
         co = compile(source, filename, 'exec')
         if module is None:
             sys.modules[name] = module = new_module(name)
-        module.__dict__.clear()
         module.__name__ = name
         module.__doc__ = None
         module.__file__ = filename
@@ -62,7 +61,6 @@
         initfilename = os.path.join(filename, '__init__.py')
         if module is None:
             sys.modules[name] = module = new_module(name)
-        module.__dict__.clear()
         module.__name__ = name
         module.__doc__ = None
         module.__file__ = initfilename

Modified: pypy/dist/pypy/module/builtin/importing.py
==============================================================================
--- pypy/dist/pypy/module/builtin/importing.py	(original)
+++ pypy/dist/pypy/module/builtin/importing.py	Tue May  3 15:17:42 2005
@@ -21,6 +21,7 @@
         w_mod = space.wrap(Module(space, w_modulename))
         space.sys.setmodule(w_mod)
         space.setattr(w_mod, w('__file__'), w(f))
+        space.setattr(w_mod, w('__doc__'), space.w_None)        
         if pkgdir is not None:
             space.setattr(w_mod, w('__path__'), space.newlist([w(pkgdir)]))
         w_dict = space.getattr(w_mod, w('__dict__'))
@@ -137,9 +138,15 @@
 
     if w_fromlist is not None and space.is_true(w_fromlist):
         if w_path is not None:
-            for w_name in space.unpackiterable(w_fromlist):
-                load_part(space, w_path, prefix, space.str_w(w_name), w_mod,
-                          tentative=1)
+            fromlist_w = space.unpackiterable(w_fromlist)
+            if len(fromlist_w) == 1 and space.eq_w(fromlist_w[0],w('*')):
+                w_all = try_getattr(space, w_mod, w('__all__'))
+                if w_all is not None:
+                    fromlist_w = space.unpackiterable(w_all)
+            for w_name in fromlist_w:
+                if try_getattr(space, w_mod, w_name) is None:
+                    load_part(space, w_path, prefix, space.str_w(w_name), w_mod,
+                              tentative=1)
         return w_mod
     else:
         return first



More information about the Pypy-commit mailing list