summaryrefslogtreecommitdiff
path: root/Lib/importlib/util.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.5] bpo-29537: Tolerate legacy invalid bytecode (#169)Nick Coghlan2017-03-081-1/+1
| | | | | | | | | | | | | | | | | | bpo-27286 fixed a problem where BUILD_MAP_UNPACK_WITH_CALL could be emitted with an incorrect oparg value, causing the eval loop to access the wrong stack entry when attempting to read the function name. The associated magic number change caused significant problems when attempting to upgrade to 3.5.3 for anyone that relies on pre-cached bytecode remaining valid across maintenance releases. This patch restores the ability to import legacy bytecode generated by 3.5.0, 3.5.1 or 3.5.2, and modifies the eval loop to avoid any harmful consequences from the potentially malformed legacy bytecode. Original import patch by Petr Viktorin, eval loop patch by Serhiy Storchaka, and tests and integration by Nick Coghlan.
* Fix a scoping issue where an UnboundLocalError was triggered if aBrett Cannon2016-06-251-1/+1
| | | | lazy-loaded module was already in sys.modules.
* Issue #26186: Remove an invalid type check inBrett Cannon2016-02-201-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 #23911: Move path-based bootstrap code to a separate frozen module.Eric Snow2015-05-021-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-061-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-141-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.