Author: Antonio Cuni <anto.c...@gmail.com> Branch: dummy-importlib Changeset: r98333:0deaee5041b4 Date: 2019-12-19 14:12 +0100 http://bitbucket.org/pypy/pypy/changeset/0deaee5041b4/
Log: tweaks diff --git a/pypy/module/_dummy_importlib/interp_import.py b/pypy/module/_dummy_importlib/interp_import.py --- a/pypy/module/_dummy_importlib/interp_import.py +++ b/pypy/module/_dummy_importlib/interp_import.py @@ -1,8 +1,20 @@ import py -from pypy.interpreter.gateway import interp2app, unwrap_spec +from pypy.interpreter.gateway import unwrap_spec from pypy.interpreter.error import OperationError from pypy.module.imp.importing import add_module, check_sys_modules_w +def raise_ImportError(space, modname): + err = """ + You are using _dummy_importlib: this is not supposed to be a + fully-compatible importing library, but it contains just enough logic to + run most of the tests. If you are experiencing problems with it, consider + adding more logic, or to switch to the fully-working _frozen_importlib by + adding this line to your AppTest class: + + spaceconfig = {'usemodules': ['_frozen_importlib']} + """ + raise OperationError(space.w_ImportError, space.newtext(modname + '\n' + err)) + @unwrap_spec(name='text0', level=int) def importhook(space, name, w_globals=None, @@ -31,18 +43,7 @@ if pydir.check(dir=True) and pyinit.check(file=True): return import_pyfile(space, name, pyinit) - - err = """ - You are using _dummy_importlib: this is not supposed to be a - fully-compatible importing library, but it contains just enough logic to - run most of the tests. If you are experiencing problems with it, consider - adding more logic, or to switch to the fully-working _frozen_importlib by - adding this line to your AppTest class: - - spaceconfig = {'usemodules': ['_frozen_importlib']} - """ - raise OperationError(space.w_ImportError, space.newtext(name + err)) -importhook = interp2app(importhook, app_name='__import__') + raise_ImportError(name) def import_pyfile(space, modulename, pyfile): diff --git a/pypy/module/_dummy_importlib/moduledef.py b/pypy/module/_dummy_importlib/moduledef.py --- a/pypy/module/_dummy_importlib/moduledef.py +++ b/pypy/module/_dummy_importlib/moduledef.py @@ -1,6 +1,8 @@ from pypy.interpreter.mixedmodule import MixedModule +from pypy.interpreter.gateway import interp2app from pypy.module._dummy_importlib import interp_import + class Module(MixedModule): interpleveldefs = { } @@ -11,7 +13,8 @@ def install(self): """NOT_RPYTHON""" super(Module, self).install() - self.w_import = self.space.wrap(interp_import.importhook) + self.w_import = self.space.wrap(interp2app(interp_import.importhook, + app_name = '__dummy_import__')) def startup(self, space): """Copy our __import__ to builtins.""" _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit