summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/abc.py
Commit message (Collapse)AuthorAgeFilesLines
* 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.