summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/util.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-43720: Update import-related stdlib deprecation messages to say they ↵Brett Cannon2021-04-031-3/+6
| | | | will be removed in Python 3.12 (GH-25167)
* bpo-42403: Fix pyflakes warnings in importlib (GH-23396)Victor Stinner2020-11-191-1/+0
| | | Remove unused imports and unused local variables.
* bpo-41006: importlib.util no longer imports typing (GH-20938)Victor Stinner2020-06-171-2/+2
| | | | Create importlib._abc submodule to avoid importing typing when importlib.util is imported. Move Loader ABC into importlib._abc.
* bpo-37444: Update differing exception between builtins and importlib (GH-14869)Ngalim Siregar2019-08-031-2/+2
| | | | | | | | | | Imports now raise `TypeError` instead of `ValueError` for relative import failures. This makes things consistent between `builtins.__import__` and `importlib.__import__` as well as using a more natural import for the failure. https://bugs.python.org/issue37444 Automerge-Triggered-By: @brettcannon
* bpo-30436: Add missing space in importlib.util.find_spec() error message ↵Zackery Spytz2018-06-071-1/+1
| | | | (GH-7385)
* closes bpo-31650: PEP 552 (Deterministic pycs) implementation (#4575)Benjamin Peterson2017-12-091-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Python now supports checking bytecode cache up-to-dateness with a hash of the source contents rather than volatile source metadata. See the PEP for details. While a fairly straightforward idea, quite a lot of code had to be modified due to the pervasiveness of pyc implementation details in the codebase. Changes in this commit include: - The core changes to importlib to understand how to read, validate, and regenerate hash-based pycs. - Support for generating hash-based pycs in py_compile and compileall. - Modifications to our siphash implementation to support passing a custom key. We then expose it to importlib through _imp. - Updates to all places in the interpreter, standard library, and tests that manually generate or parse pyc files to grok the new format. - Support in the interpreter command line code for long options like --check-hash-based-pycs. - Tests and documentation for all of the above.
* bpo-30436: Raise ModuleNotFoundError for importlib.util.find_spec() when ↵Milan Oberkirch2017-06-141-3/+8
| | | | | parent isn't a package (GH-1899) Previously AttributeError was raised, but that's not very reflective of the fact that the requested module can't be found since the specified parent isn't actually a package.
* Issue #26186: Remove the restriction that built-in and extensionBrett Cannon2016-06-251-13/+11
| | | | | | | | modules can't be lazily loaded. Thanks to Python 3.6 allowing for types.ModuleType to have its __class__ mutated, the restriction can be lifted by calling create_module() on the wrapped loader.
* Merge from 3.5Brett Cannon2016-06-251-1/+1
|\
| * Fix a scoping issue where an UnboundLocalError was triggered if aBrett Cannon2016-06-251-1/+1
| | | | | | | | lazy-loaded module was already in sys.modules.
* | Merge for issue #26186Brett Cannon2016-02-211-5/+0
|\ \ | |/
| * Issue #26186: Remove an invalid type check inBrett Cannon2016-02-211-5/+0
| | | | | | | | | | | | | | | | | | | | | | importlib.util.LazyLoader. The class was checking its argument as to whether its implementation of create_module() came directly from importlib.abc.Loader. The problem is that the classes coming from imoprtlib.machinery do not directly inherit from the ABC as they come from _frozen_importlib. Because the documentation has always said that create_module() was ignored, the check has simply been removed.
* | Issue #25771: Tweak ValueError message when package isn't specifiedBrett Cannon2015-12-041-2/+2
|/ | | | | | for importlib.util.resolve_name() but is needed. Thanks to Martin Panter for the bug report.
* Issue #23911: Move path-based bootstrap code to a separate frozen module.Eric Snow2015-05-031-6/+6
|
* Issue #19720: Suppressed context for some exceptions in importlib.Serhiy Storchaka2014-11-211-2/+2
|
* Issue #20383: Introduce importlib.util.module_from_spec().Brett Cannon2014-05-301-0/+1
| | | | | | Along the way, dismantle importlib._bootstrap._SpecMethods as it was no longer relevant and constructing the new function required partially dismantling the class anyway.
* Issue #17621: Introduce importlib.util.LazyLoader.Brett Cannon2014-04-041-1/+93
|
* Issue 19944: Fix importlib.find_spec() so it imports parents as needed.Eric Snow2014-01-251-0/+72
| | | | The function is also moved to importlib.util.
* Issue 19713: Add PEP 451-related deprecations.Eric Snow2014-01-071-5/+15
|
* Implement PEP 451 (ModuleSpec).Eric Snow2013-11-221-7/+58
|
* Issue #18076: Introduce imoportlib.util.decode_source().Brett Cannon2013-06-161-0/+1
| | | | | | | 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.
* Issue #17907: touch up the code for imp.new_module().Brett Cannon2013-06-151-0/+2
|
* Issue #18192: Introduce importlib.util.MAGIC_NUMBER and document theBrett Cannon2013-06-141-0/+1
| | | | deprecation of imp.get_magic().
* fix whitespaceBrett Cannon2013-05-311-1/+1
|
* Issues #18088, 18089: IntroduceBrett Cannon2013-05-311-1/+44
| | | | | | | | | | | | | | | | | | | | | 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.
* Rename importlib.util.ModuleManager to module_to_load so that the nameBrett Cannon2013-05-301-1/+1
| | | | explains better what the context manager is providing.
* Introduce importlib.util.ModuleManager which is a context manager toBrett Cannon2013-05-281-0/+1
| | | | | | | | 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.
* Add importlib.util.resolve_name().Brett Cannon2012-05-131-0/+16
|
* PEP 3147Barry Warsaw2010-04-171-0/+1
|
* Implement importlib.util.set_loader: a decorator to automatically setBrett Cannon2009-03-101-0/+1
| | | | __loader__ on modules.
* Rename importlib.util.set___package__ to set_package.Brett Cannon2009-03-041-1/+1
|
* Expose importlib.util.set___package__.Brett Cannon2009-03-021-0/+1
|
* Implement the more specific PEP 302 semantics for loaders and what happens uponBrett Cannon2009-02-171-0/+2
load failure in relation to reloads. Also expose importlib.util.module_for_loader to handle all of the details of this along with making sure all current loaders behave nicely.