[pypy-svn] r74765 - pypy/trunk/pypy/module/imp

afa at codespeak.net afa at codespeak.net
Wed May 26 10:49:14 CEST 2010


Author: afa
Date: Wed May 26 10:49:13 2010
New Revision: 74765

Modified:
   pypy/trunk/pypy/module/imp/importing.py
Log:
The flow object space executes all 'import' statements in a function it processes,
regardless of the values in the "config" object.
Move the actual import of the cpyext module in another function,
so that --withoutmod-cpyext doesn't try the import.


Modified: pypy/trunk/pypy/module/imp/importing.py
==============================================================================
--- pypy/trunk/pypy/module/imp/importing.py	(original)
+++ pypy/trunk/pypy/module/imp/importing.py	Wed May 26 10:49:13 2010
@@ -356,6 +356,12 @@
     if pkgdir is not None:
         space.setattr(w_mod, w('__path__'), space.newlist([w(pkgdir)]))
 
+def load_c_extension(space, filename, modulename):
+    # the next line is mandatory to init cpyext
+    space.getbuiltinmodule("cpyext")
+    from pypy.module.cpyext.api import load_extension_module
+    load_extension_module(space, filename, modulename)
+
 @jit.dont_look_inside
 def load_module(space, w_modulename, find_info, reuse=False):
     if find_info is None:
@@ -408,10 +414,7 @@
                 w_mod = check_sys_modules(space, w_modulename)
                 return w_mod
             elif find_info.modtype == C_EXTENSION and space.config.objspace.usemodules.cpyext:
-                # the next line is mandantory to init cpyext
-                space.getbuiltinmodule("cpyext")
-                from pypy.module.cpyext.api import load_extension_module
-                load_extension_module(space, find_info.filename, space.str_w(w_modulename))
+                load_c_extension(space, find_info.filename, space.str_w(w_modulename))
                 return check_sys_modules(space, w_modulename)
         except OperationError:
             w_mods = space.sys.get('modules')



More information about the Pypy-commit mailing list