mirror of https://github.com/python/cpython
0dbb4c7f13
importlib.abc.Loader.init_module_attrs() and implement importlib.abc.InspectLoader.load_module(). The importlib.abc.Loader.init_module_attrs() method sets the various attributes on the module being loaded. It is done unconditionally to support reloading. Typically people used importlib.util.module_for_loader, but since that's a decorator there was no way to override it's actions, so init_module_attrs() came into existence to allow for overriding. This is also why module_for_loader is now pending deprecation (having its other use replaced by importlib.util.module_to_load). All of this allowed for importlib.abc.InspectLoader.load_module() to be implemented. At this point you can now implement a loader with nothing more than get_code() (which only requires get_source(); package support requires is_package()). Thanks to init_module_attrs() the implementation of load_module() is basically a context manager containing 2 methods calls, a call to exec(), and a return statement. |
||
---|---|---|
.. | ||
Python-ast.c | ||
_warnings.c | ||
asdl.c | ||
ast.c | ||
bltinmodule.c | ||
ceval.c | ||
ceval_gil.h | ||
codecs.c | ||
compile.c | ||
condvar.h | ||
dtoa.c | ||
dup2.c | ||
dynamic_annotations.c | ||
dynload_aix.c | ||
dynload_dl.c | ||
dynload_hpux.c | ||
dynload_next.c | ||
dynload_shlib.c | ||
dynload_stub.c | ||
dynload_win.c | ||
errors.c | ||
fileutils.c | ||
formatter_unicode.c | ||
frozen.c | ||
frozenmain.c | ||
future.c | ||
getargs.c | ||
getcompiler.c | ||
getcopyright.c | ||
getcwd.c | ||
getopt.c | ||
getplatform.c | ||
getversion.c | ||
graminit.c | ||
import.c | ||
importdl.c | ||
importdl.h | ||
importlib.h | ||
makeopcodetargets.py | ||
marshal.c | ||
modsupport.c | ||
mysnprintf.c | ||
mystrtoul.c | ||
opcode_targets.h | ||
peephole.c | ||
pyarena.c | ||
pyctype.c | ||
pyfpe.c | ||
pymath.c | ||
pystate.c | ||
pystrcmp.c | ||
pystrtod.c | ||
pythonrun.c | ||
pytime.c | ||
random.c | ||
sigcheck.c | ||
strdup.c | ||
structmember.c | ||
symtable.c | ||
sysmodule.c | ||
thread.c | ||
thread_foobar.h | ||
thread_nt.h | ||
thread_pth.h | ||
thread_pthread.h | ||
traceback.c |