[pypy-svn] r77811 - in pypy/branch/fast-forward/pypy/module/imp: . test

afa at codespeak.net afa at codespeak.net
Tue Oct 12 01:40:28 CEST 2010


Author: afa
Date: Tue Oct 12 01:40:25 2010
New Revision: 77811

Modified:
   pypy/branch/fast-forward/pypy/module/imp/importing.py
   pypy/branch/fast-forward/pypy/module/imp/test/test_import.py
Log:
__import__ accepts anything for its "globals" and "locals" :-(
Seen in lib2to3::
    pkg = __import__(fixer_pkg, [], [], ["*"])


Modified: pypy/branch/fast-forward/pypy/module/imp/importing.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/imp/importing.py	(original)
+++ pypy/branch/fast-forward/pypy/module/imp/importing.py	Tue Oct 12 01:40:25 2010
@@ -107,7 +107,7 @@
     rel_modulename = None
     if (level != 0 and
         w_globals is not None and
-        not space.is_w(w_globals, space.w_None)):
+        space.isinstance_w(w_globals, space.w_dict)):
         ctxt_w_name = space.finditem(w_globals, w('__name__'))
         ctxt_w_path = space.finditem(w_globals, w('__path__'))
         if ctxt_w_name is not None:

Modified: pypy/branch/fast-forward/pypy/module/imp/test/test_import.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/imp/test/test_import.py	(original)
+++ pypy/branch/fast-forward/pypy/module/imp/test/test_import.py	Tue Oct 12 01:40:25 2010
@@ -285,6 +285,8 @@
         assert sys == m
         n = __import__('sys', None, None, [''])
         assert sys == n
+        o = __import__('sys', [], [], ['']) # CPython accepts this
+        assert sys == o
 
     def test_import_relative_back_to_absolute2(self):
         from pkg import abs_x_y



More information about the Pypy-commit mailing list