summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test/source
Commit message (Collapse)AuthorAgeFilesLines
* Issue #15168: Move importlb.test to test.test_importlib.Brett Cannon2012-07-208-1852/+0
| | | | | This should make the Linux distros happy as it is now easier to leave importlib's tests out of their base Python distribution.
* Closes #15030: Make importlib.abc.PyPycLoader respect the new .pycBrett Cannon2012-07-021-2/+6
| | | | | | | file size header field. Thanks to Marc Abramowitz and Ronan Lamy for helping out with various parts of the patch.
* Use assertIsNone. Thanks Terry Reedy.Eric V. Smith2012-06-281-1/+1
|
* Changed importlib tests to use assertIs, assertIsInstance, etc., instead of ↵Eric V. Smith2012-06-273-18/+17
| | | | just assertTrue.
* Fixes issue 15039: namespace packages are no longer imported in preference ↵Eric V. Smith2012-06-241-1/+1
| | | | to modules of the same name.
* Issue #14938: importlib.abc.SourceLoader.is_package() now takes theBrett Cannon2012-06-161-2/+3
| | | | | | | | | module name into consideration when determining whether a module is a package or not. This prevents importing a module's __init__ module directly and having it considered a package, which can lead to duplicate sub-modules. Thanks to Ronan Lamy for reporting the bug.
* issue 14660: Implement PEP 420, namespace packages.Eric V. Smith2012-05-251-19/+0
|
* Issue #13959: HaveBrett Cannon2012-05-111-0/+35
| | | | | | | | | | importlib.abc.FileLoader.load_module()/get_filename() and importlib.machinery.ExtensionFileLoader.load_module() have their single argument be optional as the loader's constructor has all the ncessary information. This allows for the deprecation of imp.load_source()/load_compile()/load_package().
* Issue #13959: Deprecate imp.get_suffixes() for new attributes onBrett Cannon2012-05-113-18/+19
| | | | | | | | | | | importlib.machinery that provide the suffix details for import. The attributes were not put on imp so as to compartmentalize everything importlib needs for setting up imports in importlib.machinery. This also led to an indirect deprecation of inspect.getmoduleinfo() as it directly returned imp.get_suffix's returned tuple which no longer makes sense.
* Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py.Brett Cannon2012-05-043-7/+7
| | | | | | This introduces a new function, imp.extension_suffixes(), which is currently undocumented. That is forthcoming once issue #14657 is resolved and how to expose file suffixes is decided.
* Issue #14605: Rename _SourcelessFileLoader to SourcelessFileLoader.Marc-Andre Lemburg2012-04-253-3/+3
| | | | | 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-253-3/+3
| | | | the buildbots to fail.
* Issue #14605: Rename _SourcelessFileLoader to SourcelessFileLoaderMarc-Andre Lemburg2012-04-243-3/+3
|
* Issue #14605: Expose importlib.abc.FileLoader andBrett Cannon2012-04-225-21/+36
| | | | | | | | importlib.machinery.(FileFinder, SourceFileLoader, _SourcelessFileLoader, ExtensionFileLoader). This exposes all of importlib's mechanisms that will become public on the sys module.
* Issue #2377: Make importlib the implementation of __import__().Brett Cannon2012-04-144-7/+9
| | | | | | | importlib._bootstrap is now frozen into Python/importlib.h and stored as _frozen_importlib in sys.modules. Py_Initialize() loads the frozen code along with sys and imp and then uses _frozen_importlib._install() to set builtins.__import__() w/ _frozen_importlib.__import__().
* Have importlib take advantage of ImportError's new 'name' and 'path'Brett Cannon2012-04-132-8/+19
| | | | attributes.
* Update importlib.invalidate_caches() to be more general.Brett Cannon2012-02-271-0/+7
|
* Issue #13890: Fix importlib case-sensitivity tests to not run on Windows.Brett Cannon2012-01-301-0/+6
| | | | | | | Thanks to os.environ under Windows only updating the dict and not the environment itself (as exposed by nt.environ), tests using PYTHONCASEOK always fail. Now the tests are skipped when os.environ does not do what is expected.
* Move some code from importlib.__init__ to importlib._bootstrap thatBrett Cannon2012-01-251-4/+4
| | | | does not need to be exposed from C code for bootstrapping reasons.
* Port import fixes from 2.7.Antoine Pitrou2012-01-251-1/+1
|\
| * Port import fixes from 2.7.Antoine Pitrou2012-01-251-1/+1
| |
* | Port remaining test fixes, and fix test_importlib too.Antoine Pitrou2012-01-251-1/+9
|\ \ | |/
| * Port remaining test fixes, and fix test_importlib too.Antoine Pitrou2012-01-251-1/+9
| |
* | Issue #11235: Fix OverflowError when trying to import a source file whose ↵Antoine Pitrou2012-01-241-0/+17
|\ \ | |/ | | | | modification time doesn't fit in a 32-bit timestamp.
| * Issue #11235: Fix OverflowError when trying to import a source file whose ↵Antoine Pitrou2012-01-241-0/+17
| | | | | | | | modification time doesn't fit in a 32-bit timestamp.
* | kill useless import added by 87331661042bBenjamin Peterson2012-01-161-1/+0
| |
* | Issue #13645: pyc files now contain the size of the corresponding sourceAntoine Pitrou2012-01-132-15/+39
| | | | | | | | | | code, to avoid timestamp collisions (especially on filesystems with a low timestamp resolution) when checking for freshness of the bytecode.
* | Fix no-op tests in importlib.Antoine Pitrou2011-12-301-0/+4
|\ \ | |/
| * Fix no-op tests in importlib.Antoine Pitrou2011-12-301-0/+4
| |
* | Issue #13248: turn 3.2's PendingDeprecationWarning into 3.3's ↵Florent Xicluna2011-12-101-2/+2
|/ | | | DeprecationWarning (cgi, importlib, nntplib, smtpd).
* Closes #12291: Fixed bug which was found when doing multiple loads from one ↵Vinay Sajip2011-07-021-1/+1
| | | | stream.
* 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.
* Make importlib.abc.SourceLoader the primary mechanism for importlib.Brett Cannon2010-07-031-25/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Make importlib.abc.SourceLoader the primary mechanism for importlib.Brett Cannon2010-07-036-107/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-4/+3
| | | | | | | | | | | 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-271-6/+394
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Repair test failure. Bug 8727.Barry Warsaw2010-05-181-0/+3
|
* PEP 3147Barry Warsaw2010-04-174-14/+29
|
* Importlib was not matching import's handling of .pyc files where it had lessBrett Cannon2010-02-191-24/+99
| | | | | | then 8 bytes total in the file. Fixes issues 7361 & 7875.
* When trying to write new bytecode, importlib was not catching the IOErrorBrett Cannon2009-11-071-0/+26
| | | | | | | 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.
* Use tempfile.mkdtemp() instead of tempfile.tempdir for where importlib placesBrett Cannon2009-11-051-11/+4
| | | | | | | source files for tests. Allows for concurrent execution of the tests by preventing various executions from trampling each other. Closes issue #7248.
* importlib.test.source.util referenced variables in the 'finally' part of aBrett Cannon2009-11-051-2/+6
| | | | try/finally which may not have been set.
* Move over to using assertRaises as a context manager for importlib tests.Brett Cannon2009-08-273-9/+12
| | | | | Obviously one shouldn't do whole sale conversions like this, but I was already going through the test code and I was bored at the airport.
* Implement the PEP 302 protocol for get_filename() asBrett Cannon2009-07-201-3/+50
| | | | | | 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.
* Some tests in importlib.test.source.test_abc_loader were testing what happensBrett Cannon2009-07-201-8/+16
| | | | | | | | when a loader is given missing or bad code object bytecode. Unfortunately an exception related to source paths was masking what the proper exception to test should be. Making the test explicitly set the environment fixed the test. The code being test was not affected.
* Update importlib.test.source.test_abc_loader to new features added in Python ↵Brett Cannon2009-07-191-17/+19
| | | | 3.1.
* convert old fail* assertions to assert*Benjamin Peterson2009-06-304-24/+24
|
* Tests for case-senstivity were not being skipped for darwin when installed on aBrett Cannon2009-05-114-35/+26
| | | | | | | case-sensitive filesystems -- which is not the default case. Along the way also fixed the skipping of tests when sys.dont_write_bytecode is true. Closes issue #5442 again.