Author: Brian Kearns <bdkea...@gmail.com> Branch: Changeset: r70043:310dcc241b1f Date: 2014-03-18 03:01 -0400 http://bitbucket.org/pypy/pypy/changeset/310dcc241b1f/
Log: only look in sys.modules if force_init=False diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -435,14 +435,12 @@ def getbuiltinmodule(self, name, force_init=False): w_name = self.wrap(name) w_modules = self.sys.get('modules') - try: - w_mod = self.getitem(w_modules, w_name) - except OperationError, e: - if not e.match(self, self.w_KeyError): - raise - else: - if not force_init: - return w_mod + if not force_init: + try: + return self.getitem(w_modules, w_name) + except OperationError, e: + if not e.match(self, self.w_KeyError): + raise # If the module is a builtin but not yet imported, # retrieve it and initialize it @@ -453,13 +451,13 @@ "getbuiltinmodule() called with non-builtin module %s", name) else: - # Add the module to sys.modules - self.setitem(w_modules, w_name, w_mod) - # And initialize it from pypy.interpreter.module import Module if isinstance(w_mod, Module): w_mod.init(self) + + # Add the module to sys.modules + self.setitem(w_modules, w_name, w_mod) return w_mod def get_builtinmodule_to_install(self): 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 @@ -574,6 +574,7 @@ def load_module(space, w_modulename, find_info, reuse=False): if find_info is None: return + if find_info.w_loader: return space.call_method(find_info.w_loader, "load_module", w_modulename) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit