[New-bugs-announce] [issue15481] Add exec_module() as part of the import loader API
Eric Snow
report at bugs.python.org
Sat Jul 28 21:33:10 CEST 2012
New submission from Eric Snow:
issue15110 introduced a new private function, _exec_module(), to the default loaders in Lib/importlib/_bootstrap.py. Doing so helped hide importlib frames from the traceback. A related fix is likely required for issue15425.
Should some general form of exec_module() be an official part of the loader API (in importlib.abc.Loader). If a loader subclasses one of the default ones, it already gets the behavior for free. Otherwise it does not benefit from the cleaner traceback (unless the author is savvy to the _exec_module() implementation detail).
Though the use of Loader._exec_module() to strip tracebacks is an implementation detail of CPython, having a public Loader.exec_module() would allow other implementations to perform a similar action. And if we found a way to move remove_importlib_frames to importlib then all the better. (Looking into traceback API improvements is on my to-do list.)
As a bonus, Loader.exec_module() would also allow loaders that wrap other loaders (yes, esoteric) to manage the execution portion of loading. I haven't given this part a lot of thought, so it may not be much of a bonus (or could even be a negative).
>From the perspective of caution, the import machinery is already pretty complicated. It may not be advisable to add to that even in this little way.
----------
assignee: eric.snow
components: Interpreter Core
messages: 166677
nosy: amaury.forgeotdarc, brett.cannon, eric.snow, pitrou
priority: normal
severity: normal
status: open
title: Add exec_module() as part of the import loader API
type: enhancement
versions: Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15481>
_______________________________________
More information about the New-bugs-announce
mailing list