[pypy-svn] r4797 - in pypy/trunk/src/pypy/module: . test

hpk at codespeak.net hpk at codespeak.net
Tue Jun 1 12:59:36 CEST 2004


Author: hpk
Date: Tue Jun  1 12:59:36 2004
New Revision: 4797

Modified:
   pypy/trunk/src/pypy/module/__builtin__interp.py
   pypy/trunk/src/pypy/module/test/test_import.py
Log:
fixed a problem with default arguments of __import__ 



Modified: pypy/trunk/src/pypy/module/__builtin__interp.py
==============================================================================
--- pypy/trunk/src/pypy/module/__builtin__interp.py	(original)
+++ pypy/trunk/src/pypy/module/__builtin__interp.py	Tue Jun  1 12:59:36 2004
@@ -90,11 +90,12 @@
               space.wrap("__import__() argument 1 must be string" + helper))
     w = space.wrap
 
-    ctxt_w_name = None
-    ctxt_w_path = None
-    if w_globals is not None:
+    if w_globals is not None and not space.is_true(space.is_(w_globals, space.w_None)):
         ctxt_w_name = try_getitem(w_globals,w('__name__'))
         ctxt_w_path = try_getitem(w_globals,w('__path__'))
+    else:
+        ctxt_w_name = None
+        ctxt_w_path = None
 
     rel_modulename = None
     if ctxt_w_name is not None:

Modified: pypy/trunk/src/pypy/module/test/test_import.py
==============================================================================
--- pypy/trunk/src/pypy/module/test/test_import.py	(original)
+++ pypy/trunk/src/pypy/module/test/test_import.py	Tue Jun  1 12:59:36 2004
@@ -125,6 +125,13 @@
             import pkg_r.inpkg
         self.assertRaises(ImportError,imp)
 
+    def test_import_Globals_Are_None(self):
+        import sys
+        m = __import__('sys')
+        self.assertEquals(sys, m) 
+        n = __import__('sys', None, None, [''])
+        self.assertEquals(sys, n) 
+
     def test_import_relative_back_to_absolute2(self):
         from pkg import abs_x_y
         import sys



More information about the Pypy-commit mailing list