summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/abc.py
Commit message (Collapse)AuthorAgeFilesLines
* Issue #19719: Update various finder and loader ABCs such that theirBrett Cannon2014-01-071-6/+26
| | | | | | | old methods now provide implementations when PEP 451 APIs are present. This should help with backwards-compatibility with code which has not been updated to work with PEP 451.
* Issue 19713: Add PEP 451-related deprecations.Eric Snow2014-01-071-5/+8
|
* Implement PEP 451 (ModuleSpec).Eric Snow2013-11-221-49/+53
|
* [issue 19152] Ensure we have actually registered ExtensionFileLoader as an ↵Eric Snow2013-10-051-2/+2
| | | | ExecutionLoader.
* [issue19152] Add ExtensionFileLoader.get_filename().Eric Snow2013-10-031-0/+2
|
* Issue #18200: Back out usage of ModuleNotFoundError (8d28d44f3a9a)Brett Cannon2013-07-041-1/+1
|
* Issues #18058, 18057: Make importlib._bootstrap.NamespaceLoaderBrett Cannon2013-06-161-1/+1
| | | | | conform the the InspectLoader ABC. Perk of this is that runpy/-m can now work with namespace packages.
* Issue #18200: Update the stdlib (except tests) to useBrett Cannon2013-06-141-1/+1
| | | | ModuleNotFoundError.
* Issues #18088, 18089: IntroduceBrett Cannon2013-05-311-5/+27
| | | | | | | | | | | | | | | | | | | | | 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.
* Docstring cleanupBrett Cannon2013-05-311-2/+3
|
* Issue #18072: Implement get_code() for importlib.abc.InspectLoader andBrett Cannon2013-05-281-5/+25
| | | | ExecutionLoader.
* Move importlib.abc.SourceLoader.source_to_code() to InspectLoader.Brett Cannon2013-05-261-0/+7
| | | | | | | 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.
* Issue #17093,17566,17567: Methods from classes in importlib.abc now raise/returnBrett Cannon2013-04-091-28/+45
| | | | | | | | | | 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.
* Issue #15641: Clean up deprecated classes from importlibAndrew Svetlov2012-11-051-177/+0
| | | | Patch by Taras Lyapun.
* Issue #15502: Refactor some code.Brett Cannon2012-08-101-4/+1
|
* Issue #15502: Finish bringing importlib.abc in line with the currentBrett Cannon2012-08-101-14/+28
| | | | | | | | | 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.
* Close #15519: Properly expose WindowsRegistryFinder in importlib and bring ↵Nick Coghlan2012-08-021-1/+1
| | | | the name into line with normal import terminology. Original patch by Eric Snow
* Issue #15502: Bring the importlib ABCs into line with the current state of ↵Nick Coghlan2012-08-021-21/+49
| | | | the import protocols given PEP 420. Original patch by Eric Snow.
* Typo.Barry Warsaw2012-07-311-2/+2
|
* Integration of importdocs from the features/pep-420 repo.Barry Warsaw2012-07-291-1/+18
|
* Closes #15030: Make importlib.abc.PyPycLoader respect the new .pycBrett Cannon2012-07-021-1/+7
| | | | | | | file size header field. Thanks to Marc Abramowitz and Ronan Lamy for helping out with various parts of the patch.
* Issue #14605: Rename _SourcelessFileLoader to SourcelessFileLoader.Marc-Andre Lemburg2012-04-251-1/+1
| | | | | This time also recreating the Python/importlib.h file to make make happy. See the ticket for details.
* Issue #14605: Revert renaming of _SourcelessFileLoader, since it causedMarc-Andre Lemburg2012-04-251-1/+1
| | | | the buildbots to fail.
* Issue #14605: Rename _SourcelessFileLoader to SourcelessFileLoaderMarc-Andre Lemburg2012-04-241-1/+1
|
* Issue #14605: Expose importlib.abc.FileLoader andBrett Cannon2012-04-221-5/+28
| | | | | | | | importlib.machinery.(FileFinder, SourceFileLoader, _SourcelessFileLoader, ExtensionFileLoader). This exposes all of importlib's mechanisms that will become public on the sys module.
* Have importlib take advantage of ImportError's new 'name' and 'path'Brett Cannon2012-04-131-7/+11
| | | | attributes.
* unused imports, pep8Philip Jenvey2012-02-251-6/+4
|
* Move some code from importlib.__init__ to importlib._bootstrap thatBrett Cannon2012-01-251-2/+2
| | | | does not need to be exposed from C code for bootstrapping reasons.
* Issue #13645: pyc files now contain the size of the corresponding sourceAntoine Pitrou2012-01-131-1/+14
| | | | | code, to avoid timestamp collisions (especially on filesystems with a low timestamp resolution) when checking for freshness of the bytecode.
* Issue #13248: turn 3.2's PendingDeprecationWarning into 3.3's ↵Florent Xicluna2011-12-101-2/+2
| | | | DeprecationWarning (cgi, importlib, nntplib, smtpd).
* Issue 10899: Remove function type annotations from the stdlibRaymond Hettinger2011-01-131-15/+21
|
* Issue 10899: Remove function type annotations from the stdlibRaymond Hettinger2011-01-131-13/+13
|
* While not strictly necessary thanks to the odd ABC inheritance done throughBrett Cannon2010-08-221-0/+14
| | | | | importlib._bootstrap, add the optional methods for importlib.abc.SourceLoader for completeness.
* Make importlib.abc.SourceLoader the primary mechanism for importlib.Brett Cannon2010-07-031-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This required moving the class from importlib/abc.py into importlib/_bootstrap.py and jiggering some code to work better with the class. This included changing how the file finder worked to better meet import semantics. This also led to fixing importlib to handle the empty string from sys.path as import currently does (and making me wish we didn't support that instead just required people to insert '.' instead to represent cwd). It also required making the new set_data abstractmethod create any needed subdirectories implicitly thanks to __pycache__ (it was either this or grow the SourceLoader ABC to gain an 'exists' method and either a mkdir method or have set_data with no data arg mean to create a directory). Lastly, as an optimization the file loaders cache the file path where the finder found something to use for loading (this is thanks to having a sourceless loader separate from the source loader to simplify the code and cut out stat calls). Unfortunately test_runpy assumed a loader would always work for a module, even if you changed from underneath it what it was expected to work with. By simply dropping the previous loader in test_runpy so the proper loader can be returned by the finder fixed the failure. At this point importlib deviates from import on two points: 1. The exception raised when trying to import a file is different (import does an explicit file check to print a special message, importlib just says the path cannot be imported as if it was just some module name). 2. the co_filename on a code object is not being set to where bytecode was actually loaded from instead of where the marshalled code object originally came from (a solution for this has already been agreed upon on python-dev but has not been implemented yet; issue8611).
* Move importlib.abc.SourceLoader to _bootstrap.Brett Cannon2010-06-281-101/+1
| | | | | | | | | | | Required updating code relying on other modules to switch to _bootstrap's unique module requirements. This led to the realization that get_code was being too liberal in its exception catching when calling set_data by blindly grabbing IOError. Shifted the responsibility of safely ignoring writes to a read-only path to set_data. Importlib is still not relying on SourceLoader yet; requires creating a SourcelessLoader and updating the source finder.
* Implement importlib.abc.SourceLoader and deprecate PyLoader and PyPycLoader.Brett Cannon2010-06-271-10/+260
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | SourceLoader is a simplification of both PyLoader and PyPycLoader. If one only wants to use source, then they need to only implement get_data and get_filename. To also use bytecode -- sourceless loading is not supported -- then two abstract methods -- path_mtime and set_data -- need to be implemented. Compared to PyLoader and PyPycLoader, there are less abstract methods introduced and bytecode files become an optimization controlled by the ABC and hidden from the user (this need came about as PEP 3147 showed that not treating bytecode as an optimization can cause problems for compatibility). PyLoader is deprecated in favor of SourceLoader. To be compatible from Python 3.1 onwards, a subclass need only use simple methods for source_path and is_package. Otherwise conditional subclassing based on whether Python 3.1 or Python 3.2 is being is the only change. The documentation and docstring for PyLoader explain what is exactly needed. PyPycLoader is deprecated also in favor of SourceLoader. Because PEP 3147 shifted bytecode path details so much, there is no foolproof way to provide backwards-compatibility with SourceLoader. Because of this the class is simply deprecated and users should move to SourceLoader (and optionally PyLoader for Python 3.1). This does lead to a loss of support for sourceless loading unfortunately. At some point before Python 3.2 is released, SourceLoader will be moved over to importlib._bootstrap so that the core code of importlib relies on the new code instead of the old PyPycLoader code. This commit is being done now so that there is no issue in having the API in Python 3.1a1.
* Clarify importlib.abc.PyPycLoader.write_bytecode().Brett Cannon2009-12-121-2/+3
|
* Implement the PEP 302 protocol for get_filename() asBrett Cannon2009-07-201-1/+17
| | | | | | importlib.abc.ExecutionLoader. PyLoader now inherits from this ABC instead of InspectLoader directly. Both PyLoader and PyPycLoader provide concrete implementations of get_filename in terms of source_path and bytecode_path.
* Importlib's documentation said that importlib.abc.PyLoader inherited fromBrett Cannon2009-07-201-1/+1
| | | | | | | | | importlib.abc.ResourceLoader, when in fact it did not. Fixed the ABC to inherit as documented. This doesn't introduce an backwards-incompatiblity as the code in PyLoader already required the single method ResourceLoader defined as an abstract method.
* Implement InspectLoader for FrozenImporter.Brett Cannon2009-03-151-2/+1
|
* Implement InspectLoader for BuiltinImporter.Brett Cannon2009-03-151-1/+2
|
* A few more docstring/API cleanups for importlib.Brett Cannon2009-03-151-25/+37
|
* Introduce importlib.abc. The module contains various ABCs related to importsBrett Cannon2009-03-091-0/+110
(mostly stuff specified by PEP 302). There are two ABCs, PyLoader and PyPycLoader, which help with implementing source and source/bytecode loaders by implementing load_module in terms of other methods. This removes a lot of gritty details loaders typically have to worry about.