[pypy-svn] r64106 - pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/__builtin__

cfbolz at codespeak.net cfbolz at codespeak.net
Wed Apr 15 18:11:39 CEST 2009


Author: cfbolz
Date: Wed Apr 15 18:11:38 2009
New Revision: 64106

Modified:
   pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/__builtin__/__init__.py
   pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/__builtin__/importing.py
Log:
(cfbolz, pedronis): Funny surprises you find from time to time: we had to
identical copies of find_module around, that differed only in their indentation.
Kill one of them.


Modified: pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/__builtin__/__init__.py
==============================================================================
--- pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/__builtin__/__init__.py	(original)
+++ pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/__builtin__/__init__.py	Wed Apr 15 18:11:38 2009
@@ -49,6 +49,7 @@
         'vars'          : 'app_inspect.vars',
         'dir'           : 'app_inspect.dir',
 
+        '_find_module'  : 'app_misc.find_module',
         'reload'        : 'app_misc.reload',
 
         '__filestub'    : 'app_file_stub.file',

Modified: pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/__builtin__/importing.py
==============================================================================
--- pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/__builtin__/importing.py	(original)
+++ pypy/branch/wip-fix-stackless-O2-pickling/pypy/module/__builtin__/importing.py	Wed Apr 15 18:11:38 2009
@@ -250,6 +250,7 @@
         return first
 
 def load_part(space, w_path, prefix, partname, w_parent, tentative):
+    w_find_module = space.getattr(space.builtin, space.wrap("_find_module"))
     w = space.wrap
     modulename = '.'.join(prefix + [partname])
     w_modulename = w(modulename)
@@ -260,9 +261,10 @@
     else:
         # Examin importhooks (PEP302) before doing the import
         if w_path is not None:
-            w_loader  = find_module(space, w_modulename, w_path) 
+            w_loader  = space.call_function(w_find_module, w_modulename, w_path)
         else:
-            w_loader  = find_module(space, w_modulename, space.w_None)
+            w_loader  = space.call_function(w_find_module, w_modulename,
+                                            space.w_None)
         if not space.is_w(w_loader, space.w_None):
             w_mod = space.call_method(w_loader, "load_module", w_modulename)
             #w_mod_ = check_sys_modules(space, w_modulename)
@@ -572,50 +574,3 @@
         except OSError:
             pass
 
-
-app = gateway.applevel(
-r"""    
-# Implement pep302
-
-IMP_HOOK = 9
-
-def find_module(fullname,  path):
-    import sys
-    meta_path = sys.meta_path
-    for hook in meta_path:
-        loader = hook.find_module(fullname,  path)
-        if loader:
-            return loader
-    if path != None and type(path) == str:
-        pass
-        # XXX Check for frozen modules ?
-    if path == None:
-        # XXX Check frozen
-        path = sys.path
-    path_hooks = sys.path_hooks
-    importer_cache = sys.path_importer_cache 
-    importer = None
-    for p in path:
-        if importer_cache.get(p,None):
-            importer = importer_cache.get(p)
-        else:
-            importer_cache[p] = None
-            importer = None
-            for hook in path_hooks:
-                try:
-                    importer = hook(p)
-                except ImportError:
-                    pass
-                else:
-                    break
-            if importer:
-                importer_cache[p] = importer
-        if importer:
-            loader = importer.find_module(fullname)
-            if loader:
-                return loader
-     #no hooks match - do normal import
-    """) 
-
-find_module = app.interphook('find_module')
-



More information about the Pypy-commit mailing list