summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
Commit message (Collapse)AuthorAgeFilesLines
* Issue #13392: Writing a pyc file should now be atomic under Windows as well.Antoine Pitrou2011-11-151-15/+20
|
* Issue #13303: Fix bytecode file default permission.Charles-François Natali2011-11-101-1/+1
|
* Issue #13303: Fix a race condition in the bytecode file creation.Charles-François Natali2011-10-311-3/+4
|
* Simplify and remove few dependencies on 'errno', thanks to PEP 3151.Florent Xicluna2011-10-282-13/+6
|
* Silence the FileExistsError which can be raised because of the O_EXCL flagAntoine Pitrou2011-10-191-7/+7
| | | | (as in import.c)
* Issue #13146: Writing a pyc file is now atomic under POSIX.Antoine Pitrou2011-10-171-3/+23
|
* Closes #12291 for 3.3 - merged fix from 3.2.Vinay Sajip2011-07-021-1/+1
|\
| * Closes #12291: Fixed bug which was found when doing multiple loads from one ↵Vinay Sajip2011-07-021-1/+1
| | | | | | | | stream.
* | Kill dead code in importlib.test.__main__ (#12019, reviewed by Brett Cannon)Éric Araujo2011-06-071-6/+1
| |
* | (Merge 3.2) Issue #11614: Fix importlib tests for the new __hello__ moduleVictor Stinner2011-05-161-9/+17
|\ \ | |/
| * (Merge 3.1) Issue #11614: Fix importlib tests for the new __hello__ moduleVictor Stinner2011-05-161-9/+17
| |\
| | * Issue #11614: Fix importlib tests for the new __hello__ moduleVictor Stinner2011-05-161-9/+17
| | |
* | | Remove a stale comment.Brett Cannon2011-03-241-7/+0
| | |
* | | Make importlib compatible with __import__ by "fixing" code.co_filenameBrett Cannon2011-03-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | paths. __import__ does a little trick when importing from bytecode by back-patching the co_filename paths to point to the file location where the code object was loaded from, *not* where the code object was originally created. This allows co_filename to point to a valid path. Problem is that co_filename is immutable from Python, so a private function -- imp._fix_co_filename() -- had to be introduced in order to get things working properly. Originally the plan was to add a file argument to marshal.loads(), but that failed as the algorithm used by __import__ is not fully recursive as one might expect, so to be fully backwards-compatible the code used by __import__ needed to be exposed. This closes issue #6811 by taking a different approach than outlined in the issue.
* | | Have importlib use the repr of a module name in error messages.Brett Cannon2011-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | | This makes it obvious that an import failed because of some extraneous whitespace (e.g., a newline). This is a partial fix for issue #8754.
* | | #11515: Merge with 3.2.Ezio Melotti2011-03-151-2/+2
|\ \ \ | |/ /
| * | #11515: Merge with 3.1.Ezio Melotti2011-03-151-2/+2
| |\ \ | | |/
| | * #11515: fix several typos. Patch by Piotr Kasprzyk.Ezio Melotti2011-03-151-1/+1
| | |
| | * Merged revisions 86596 via svnmerge fromEzio Melotti2010-11-214-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86596 | ezio.melotti | 2010-11-20 21:04:17 +0200 (Sat, 20 Nov 2010) | 1 line #9424: Replace deprecated assert* methods in the Python test suite. ........
| | * Merged revisions 78242 via svnmerge fromBrett Cannon2010-02-192-29/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r78242 | brett.cannon | 2010-02-19 11:01:06 -0500 (Fri, 19 Feb 2010) | 5 lines Importlib was not matching import's handling of .pyc files where it had less then 8 bytes total in the file. Fixes issues 7361 & 7875. ........
| | * Merged revisions 76146 via svnmerge fromBrett Cannon2009-11-072-2/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r76146 | brett.cannon | 2009-11-07 15:55:05 -0800 (Sat, 07 Nov 2009) | 6 lines When trying to write new bytecode, importlib was not catching the IOError thrown if the file happened to be read-only to keep the failure silent. Fixes issue #7187. Thanks, Dave Malcolm for the report and analysis of the problem. ........
| | * Merged revisions 76113-76114 via svnmerge fromBrett Cannon2009-11-051-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r76113 | brett.cannon | 2009-11-04 17:17:22 -0800 (Wed, 04 Nov 2009) | 3 lines importlib.test.source.util referenced variables in the 'finally' part of a try/finally which may not have been set. ........ r76114 | brett.cannon | 2009-11-04 17:26:57 -0800 (Wed, 04 Nov 2009) | 6 lines Use tempfile.mkdtemp() instead of tempfile.tempdir for where importlib places source files for tests. Allows for concurrent execution of the tests by preventing various executions from trampling each other. Closes issue #7248. ........
| | * Merged revisions 74584 via svnmerge fromBrett Cannon2009-08-302-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r74584 | brett.cannon | 2009-08-29 20:47:36 -0700 (Sat, 29 Aug 2009) | 3 lines Have importlib raise ImportError if None is found in sys.modules. This matches current import semantics. ........
| | * Merged revisions 73715 via svnmerge fromGeorg Brandl2009-08-1318-84/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://svn.python.org/python/branches/py3k ........ r73715 | benjamin.peterson | 2009-07-01 01:06:06 +0200 (Mi, 01 Jul 2009) | 1 line convert old fail* assertions to assert* ........
| | * Merged revisions 74107 via svnmerge fromBrett Cannon2009-07-202-15/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r74107 | brett.cannon | 2009-07-19 20:19:18 -0700 (Sun, 19 Jul 2009) | 8 lines Importlib's documentation said that importlib.abc.PyLoader inherited from importlib.abc.ResourceLoader, when in fact it did not. Fixed the ABC to inherit as documented. This does in introduce an backwards-incompatiblity as the code in PyLoader already required the single method ResourceLoader defined as an abstract method. ........
| | * Backport of r74103.Brett Cannon2009-07-201-8/+8
| | |
* | | Skip test if zlib not present. Closes #11498. Patch by Natalia B. Bidart.Eric V. Smith2011-03-141-1/+1
| | |
* | | Typos.Eric V. Smith2011-03-141-2/+2
|/ /
* | Issue 10899: Remove function type annotations from the stdlibRaymond Hettinger2011-01-132-18/+24
| |
* | Issue 10899: Remove function type annotations from the stdlibRaymond Hettinger2011-01-132-15/+15
| |
* | #9424: Replace deprecated assert* methods in the Python test suite.Ezio Melotti2010-11-204-23/+23
| |
* | Fix a minor inconsistency in capitalization for the 'No module named' exceptionBrett Cannon2010-11-181-3/+5
| | | | | | | | | | | | message in importlib. Thanks to Éric Araujo for spotting the inconsistency.
* | Remove redundant context manager.Florent Xicluna2010-09-031-15/+1
| |
* | OSError is the exception raised when one tries to create a directory thatBrett Cannon2010-08-261-2/+5
| | | | | | | | | | | | already exists, not IOError. Part of the continuing saga of issue #9572.
* | Fix a bug where an attribute was lacking an object to work off of.Brett Cannon2010-08-241-1/+1
| | | | | | | | | | Related to the fix for issue #9572. Thanks to Łukasz Czuja for catching the bug.
* | One of the joys of having test_multiprocessing occasionally execute afterBrett Cannon2010-08-221-18/+26
| | | | | | | | | | | | | | | | | | | | | | test_importlib is that it discovers special little race conditions. For instance, it turns out that importlib would throw an exception if two different Python processes both tried to create the __pycache__ directory as one process would succeed, causing the other process to fail as it didn't expect to get any "help". So now importlib simply stays calm and just accepts someone else did the work of creating the __pycache__ directory for it, moving on with life. Closes issue #9572.
* | Make sure that no __pycache__ directory is needlessly left behind when testingBrett Cannon2010-08-221-7/+10
| | | | | | | | imports with an empty string in sys.path.
* | 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.
* | Add importlib benchmarks which try to be "realistic" by importing the decimalBrett Cannon2010-07-221-7/+50
| | | | | | | | module which is the largest module in the stdlib.
* | Add comma grouping to max result so it's easier to read.Brett Cannon2010-07-161-1/+1
| |
* | Add benchmarks for importing just source w/o writing bytecode, importing sourceBrett Cannon2010-07-161-14/+57
| | | | | | | | | | while writing bytecode, and importing bytecode with source existing (don't care about sourceless imports).
* | Touch up comments and code along with outputting what the unit of measure is.Brett Cannon2010-07-151-7/+10
| |
* | Make importlib.abc.SourceLoader the primary mechanism for importlib.Brett Cannon2010-07-032-27/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* | Make importlib.abc.SourceLoader the primary mechanism for importlib.Brett Cannon2010-07-033-1/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* | Fix a spelling mistake in a comment.Brett Cannon2010-07-031-1/+1
| |
* | Make importlib.abc.SourceLoader the primary mechanism for importlib.Brett Cannon2010-07-0315-540/+406
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* | Add an inheritance test for importlib.abc.SourceLoader.Brett Cannon2010-06-281-0/+5
| |
* | Move importlib.abc.SourceLoader to _bootstrap.Brett Cannon2010-06-283-105/+141
| | | | | | | | | | | | | | | | | | | | | | 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.
* | fix test with more obviously incorrect bytecodeBenjamin Peterson2010-06-281-1/+1
| |
* | Implement importlib.abc.SourceLoader and deprecate PyLoader and PyPycLoader.Brett Cannon2010-06-272-16/+654
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.