[pypy-commit] pypy builtin-module: Fixes for faked modules.

arigo noreply at buildbot.pypy.org
Sun Dec 4 11:15:11 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: builtin-module
Changeset: r50107:6d9a5e6b2428
Date: 2011-12-04 11:14 +0100
http://bitbucket.org/pypy/pypy/changeset/6d9a5e6b2428/

Log:	Fixes for faked modules.

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -476,6 +476,8 @@
             for modname in self.ALL_BUILTIN_MODULES:
                 if not LIB_PYPY.join(modname+'.py').check(file=True):
                     modules.append('faked+'+modname)
+                else:
+                    modules.append('faked+__builtin_'+modname)
 
         self._builtinmodule_list = modules
         return self._builtinmodule_list
@@ -586,11 +588,15 @@
         try:
             module = self.load_cpython_module(modname)
         except ImportError:
-            return
-        else:
-            w_modules = self.sys.get('modules')
-            self.setitem(w_modules, self.wrap(modname), self.wrap(module))
-            installed_builtin_modules.append(modname)
+            if not modname.startswith('__builtin_'):
+                return
+            try:
+                module = self.load_cpython_module(modname[10:])
+            except ImportError:
+                return
+        w_modules = self.sys.get('modules')
+        self.setitem(w_modules, self.wrap(modname), self.wrap(module))
+        installed_builtin_modules.append(modname)
 
     def setup_builtin_modules(self):
         "NOT_RPYTHON: only for initializing the space."
diff --git a/pypy/module/__pypy__/test/test_special.py b/pypy/module/__pypy__/test/test_special.py
--- a/pypy/module/__pypy__/test/test_special.py
+++ b/pypy/module/__pypy__/test/test_special.py
@@ -16,7 +16,9 @@
     def test__isfake_currently_true(self):
         from __pypy__ import isfake
         import select
-        assert isfake(select)
+        assert not isfake(select)   # that's lib_pypy/select.py
+        import __builtin_select
+        assert isfake(__builtin_select)
 
     def test_cpumodel(self):
         import __pypy__


More information about the pypy-commit mailing list