[pypy-commit] pypy default: Backout 6f2534aea5ca. It's more of a mess, because

arigo noreply at buildbot.pypy.org
Fri Nov 11 14:42:30 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r49307:86c777384663
Date: 2011-11-11 14:42 +0100
http://bitbucket.org/pypy/pypy/changeset/86c777384663/

Log:	Backout 6f2534aea5ca. It's more of a mess, because e.g. we have
	lib_pypy/struct.py, but we still want the builtin module if we have
	it...

diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py
--- a/pypy/interpreter/mixedmodule.py
+++ b/pypy/interpreter/mixedmodule.py
@@ -13,7 +13,6 @@
 
     applevel_name = None
     expose__file__attribute = True
-    cannot_override_in_import_statements = False
 
     # The following attribute is None as long as the module has not been
     # imported yet, and when it has been, it is mod.__dict__.items() just
diff --git a/pypy/module/__builtin__/__init__.py b/pypy/module/__builtin__/__init__.py
--- a/pypy/module/__builtin__/__init__.py
+++ b/pypy/module/__builtin__/__init__.py
@@ -7,7 +7,6 @@
 
 class Module(MixedModule):
     """Built-in functions, exceptions, and other objects."""
-    cannot_override_in_import_statements = True
     expose__file__attribute = False
 
     appleveldefs = {
diff --git a/pypy/module/_ast/__init__.py b/pypy/module/_ast/__init__.py
--- a/pypy/module/_ast/__init__.py
+++ b/pypy/module/_ast/__init__.py
@@ -3,7 +3,6 @@
 
 
 class Module(MixedModule):
-    cannot_override_in_import_statements = True
 
     interpleveldefs = {
         "PyCF_ONLY_AST" : "space.wrap(%s)" % consts.PyCF_ONLY_AST,
diff --git a/pypy/module/_codecs/__init__.py b/pypy/module/_codecs/__init__.py
--- a/pypy/module/_codecs/__init__.py
+++ b/pypy/module/_codecs/__init__.py
@@ -37,7 +37,6 @@
 
 Copyright (c) Corporation for National Research Initiatives.
 """
-    cannot_override_in_import_statements = True
 
     appleveldefs = {}
 
diff --git a/pypy/module/_sre/__init__.py b/pypy/module/_sre/__init__.py
--- a/pypy/module/_sre/__init__.py
+++ b/pypy/module/_sre/__init__.py
@@ -1,7 +1,6 @@
 from pypy.interpreter.mixedmodule import MixedModule 
 
 class Module(MixedModule):
-    cannot_override_in_import_statements = True
 
     appleveldefs = {
     }
diff --git a/pypy/module/_warnings/__init__.py b/pypy/module/_warnings/__init__.py
--- a/pypy/module/_warnings/__init__.py
+++ b/pypy/module/_warnings/__init__.py
@@ -3,7 +3,6 @@
 class Module(MixedModule):
     """provides basic warning filtering support.
     It is a helper module to speed up interpreter start-up."""
-    cannot_override_in_import_statements = True
 
     interpleveldefs = {
         'warn'         : 'interp_warnings.warn',
diff --git a/pypy/module/_weakref/__init__.py b/pypy/module/_weakref/__init__.py
--- a/pypy/module/_weakref/__init__.py
+++ b/pypy/module/_weakref/__init__.py
@@ -1,7 +1,6 @@
 from pypy.interpreter.mixedmodule import MixedModule
     
 class Module(MixedModule):
-    cannot_override_in_import_statements = True
     appleveldefs = {
     }
     interpleveldefs = {
diff --git a/pypy/module/errno/__init__.py b/pypy/module/errno/__init__.py
--- a/pypy/module/errno/__init__.py
+++ b/pypy/module/errno/__init__.py
@@ -16,7 +16,6 @@
     To map error codes to error messages, use the function os.strerror(),
     e.g. os.strerror(2) could return 'No such file or directory'."""
 
-    cannot_override_in_import_statements = True
     appleveldefs = {}
     interpleveldefs = {"errorcode": "interp_errno.get_errorcode(space)"}
     
diff --git a/pypy/module/exceptions/__init__.py b/pypy/module/exceptions/__init__.py
--- a/pypy/module/exceptions/__init__.py
+++ b/pypy/module/exceptions/__init__.py
@@ -2,8 +2,6 @@
 from pypy.interpreter.mixedmodule import MixedModule
 
 class Module(MixedModule):
-    cannot_override_in_import_statements = True
-
     appleveldefs = {}
     
     interpleveldefs = {
diff --git a/pypy/module/gc/__init__.py b/pypy/module/gc/__init__.py
--- a/pypy/module/gc/__init__.py
+++ b/pypy/module/gc/__init__.py
@@ -1,7 +1,6 @@
 from pypy.interpreter.mixedmodule import MixedModule
     
 class Module(MixedModule):
-    cannot_override_in_import_statements = True
     appleveldefs = {
         'enable': 'app_gc.enable',
         'disable': 'app_gc.disable',
diff --git a/pypy/module/imp/__init__.py b/pypy/module/imp/__init__.py
--- a/pypy/module/imp/__init__.py
+++ b/pypy/module/imp/__init__.py
@@ -5,7 +5,6 @@
     This module provides the components needed to build your own
     __import__ function.
     """
-    cannot_override_in_import_statements = True
     interpleveldefs = {
         'PY_SOURCE':       'space.wrap(importing.PY_SOURCE)',
         'PY_COMPILED':     'space.wrap(importing.PY_COMPILED)',
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -5,7 +5,6 @@
 import sys, os, stat
 
 from pypy.interpreter.module import Module
-from pypy.interpreter.mixedmodule import MixedModule
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef, generic_new_descr
 from pypy.interpreter.error import OperationError, operationerrfmt
@@ -484,19 +483,10 @@
     # XXX Check for frozen modules?
     #     when w_path is a string
 
-    default_result = None
-
     if w_path is None:
         # check the builtin modules
-        w_mod = space.builtin_modules.get(modulename, None)
-        if w_mod is not None:
-            default_result = FindInfo(C_BUILTIN, modulename, None)
-            mod = space.interpclass_w(w_mod)
-            if (isinstance(mod, MixedModule) and
-                mod.cannot_override_in_import_statements):
-                return default_result
-            #else:
-            #   continue looking and only return it if no xxx.py found
+        if modulename in space.builtin_modules:
+            return FindInfo(C_BUILTIN, modulename, None)
         w_path = space.sys.get('path')
 
     # XXX check frozen modules?
@@ -540,7 +530,7 @@
                        # Out of file descriptors.
 
     # not found
-    return default_result
+    return None
 
 def _prepare_module(space, w_mod, filename, pkgdir):
     w = space.wrap
diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -918,34 +918,6 @@
                 finally:
                     stream.close()
 
-    def test_cannot_hide_builtin_exceptions(self):
-        import sys, os
-        filename = os.path.join(sys.path[0], 'exceptions.py')
-        f = open(filename, 'w')
-        f.close()
-        try:
-            import exceptions
-            assert hasattr(exceptions, 'NotImplementedError')
-        finally:
-            os.unlink(filename)
-
-    def test_can_hide_builtin_parser(self):
-        import sys, os
-        filename = os.path.join(sys.path[0], 'parser.py')
-        f = open(filename, 'w')
-        f.write('I_have_been_hidden = 42\n')
-        f.close()
-        old = sys.modules.pop('parser', None)
-        try:
-            import parser
-            assert hasattr(parser, 'I_have_been_hidden')
-        finally:
-            os.unlink(filename)
-            if old is not None:
-                sys.modules['parser'] = old
-            else:
-                del sys.modules['parser']
-
 
 def test_PYTHONPATH_takes_precedence(space): 
     if sys.platform == "win32":
diff --git a/pypy/module/marshal/__init__.py b/pypy/module/marshal/__init__.py
--- a/pypy/module/marshal/__init__.py
+++ b/pypy/module/marshal/__init__.py
@@ -5,7 +5,6 @@
     """
     This module implements marshal at interpreter level.
     """
-    cannot_override_in_import_statements = True
 
     appleveldefs = {
     }
diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -30,7 +30,6 @@
 disguised Unix interface).  Refer to the library manual and
 corresponding Unix manual entries for more information on calls."""
 
-    cannot_override_in_import_statements = True
     applevel_name = os.name
 
     appleveldefs = {
diff --git a/pypy/module/pwd/__init__.py b/pypy/module/pwd/__init__.py
--- a/pypy/module/pwd/__init__.py
+++ b/pypy/module/pwd/__init__.py
@@ -11,7 +11,6 @@
     The uid and gid items are integers, all others are strings. An
     exception is raised if the entry asked for cannot be found.
     """
-    cannot_override_in_import_statements = True
 
     interpleveldefs = {
         'getpwuid': 'interp_pwd.getpwuid',
diff --git a/pypy/module/signal/__init__.py b/pypy/module/signal/__init__.py
--- a/pypy/module/signal/__init__.py
+++ b/pypy/module/signal/__init__.py
@@ -4,7 +4,6 @@
 import signal as cpy_signal
 
 class Module(MixedModule):
-    cannot_override_in_import_statements = True
     interpleveldefs = {
         'signal':              'interp_signal.signal',
         'getsignal':           'interp_signal.getsignal',
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -8,7 +8,6 @@
 class Module(MixedModule):
     """Sys Builtin Module. """
     _immutable_fields_ = ["defaultencoding?"]
-    cannot_override_in_import_statements = True
 
     def __init__(self, space, w_name):
         """NOT_RPYTHON""" # because parent __init__ isn't
diff --git a/pypy/module/thread/__init__.py b/pypy/module/thread/__init__.py
--- a/pypy/module/thread/__init__.py
+++ b/pypy/module/thread/__init__.py
@@ -3,8 +3,6 @@
 from pypy.interpreter.mixedmodule import MixedModule
 
 class Module(MixedModule):
-    cannot_override_in_import_statements = True
-
     appleveldefs = {
     }
 
diff --git a/pypy/module/zipimport/__init__.py b/pypy/module/zipimport/__init__.py
--- a/pypy/module/zipimport/__init__.py
+++ b/pypy/module/zipimport/__init__.py
@@ -5,7 +5,6 @@
 from pypy.interpreter.mixedmodule import MixedModule
 
 class Module(MixedModule):
-    cannot_override_in_import_statements = True
 
     interpleveldefs = {
         'zipimporter':'interp_zipimport.W_ZipImporter',


More information about the pypy-commit mailing list