| Commit message (Collapse) | Author | Age | Files | Lines |
|\ |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|\ \
| |/ |
|
| | |
|
| | |
|
|\ \
| |/ |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
The helper function makes it easier to implement
imoprtlib.abc.InspectLoader.get_source() by making that function
require just the raw bytes for source code and handling all other
details.
|
| | |
|
| |
| |
| |
| | |
deprecation of imp.get_magic().
|
| |
| |
| |
| |
| |
| | |
implementing in code) the deprecation of imp.reload().
Thanks to Berker Peksag for the patch.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| | |
control whether to reset the module's __name__ attribute in case a
reload is being done.
|
| | |
|
| |
| |
| |
| | |
explains better what the context manager is providing.
|
| | |
|
| |
| |
| |
| |
| | |
and __package__ unconditionally in order to do the right thing for
reloading.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
handle providing (and cleaning up if needed) the module to be loaded.
A future commit will use the context manager in
Lib/importlib/_bootstrap.py and thus why the code is placed there
instead of in Lib/importlib/util.py.
|
| |
| |
| |
| | |
ExecutionLoader.
|
| |
| |
| |
| |
| |
| |
| | |
While the previous location was fine, it makes more sense to have the
method higher up in the inheritance chain, especially at a point where
get_source() is defined which is the earliest source_to_code() could
programmatically be used in the inheritance tree in importlib.abc.
|
|\ \
| |/ |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
attributes to None.
The long-term goal is for people to be able to rely on these
attributes existing and checking for None to see if they have been
set. Since import itself sets these attributes when a loader does not
the only instances when the attributes are None are from someone
overloading __import__() and not using a loader or someone creating a
module from scratch.
This patch also unifies module initialization. Before you could have
different attributes with default values depending on how the module
object was created. Now the only way to not get the same default set
of attributes is to circumvent initialization by calling
ModuleType.__new__() directly.
|
|\ \
| |/ |
|
| |
| |
| |
| | |
importlib.invalidate_caches().
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
the default exception/value when called instead of raising/returning
NotimplementedError/NotImplemented (except where appropriate).
This should allow for the ABCs to act as the bottom/end of the MRO with expected
default results.
As part of this work, also make importlib.abc.Loader.module_repr()
optional instead of an abstractmethod.
|
| |
| |
| |
| |
| |
| | |
__loader__ is not set on a module. This brings the exception in line
with when __loader__ is None (which is equivalent to not having the
attribute defined).
|
| |
| |
| |
| |
| |
| | |
set __loader__ on a module when set to None.
Thanks to Gökcen Eraslan for the fix.
|
|\ \
| |/ |
|
| | |
|
| |
| |
| |
| |
| |
| | |
added
to importlib.abc.SourceLoader.
|
| |
| |
| |
| |
| |
| |
| | |
importlib.abc.SourceLoader.
This provides an easy hook into the import system to allow for source
transformations, AST optimizations, etc.
|
|\ \
| |/ |
|
| |
| |
| |
| | |
the user to import any parent packages.
|
|/
|
|
| |
Patch by Taras Lyapun.
|
| |
|
|
|
|
|
|
|
| |
The code for the class itself isn't deprecated for
backwards-compatibility reasons, but the class shouldn't be directly
inherited by anyone anymore as the API is no longer as widely valid as
it used to be.
|
|\
| |
| |
| | |
Patch by Chris Jerdonek.
|
| | |
|
| |
| |
| |
| | |
Patch by Chris Jerdonek.
|
| | |
|
| | |
|
| |
| |
| |
| |
| | |
module again. Also took the opportunity to stop accidentally exporting
_imp.extension_suffixes() as public.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
state of the import system. Also make importlib.invalidate_caches()
work with sys.meta_path instead of sys.path_importer_cache to
completely separate the path-based import system from the overall
import system.
Patch by Eric Snow.
|