summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zipimport.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059)Barry Warsaw2023-05-031-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove deprecated classes from pkgutil * Remove some other PEP 302 obsolescence * Use find_spec instead of load_module * Remove more tests of PEP 302 obsolete APIs * Remove another bunch of tests using obsolete load_modules() * Remove deleted names from __all__ * Remove obsolete footnote * imp is removed * Remove `imp` from generated stdlib names * What's new and blurb * Update zipimport documentation for the removed methods * Fix some Windows tests * Remove any test (or part of a test) that references `find_module()`. * Use assertIsNone() / assertIsNotNone() consistently. * Update Doc/reference/import.rst * We don't need pkgutil._get_spec() any more either * test.test_importlib.fixtures.NullFinder * ...BadLoaderFinder.find_module * ...test_api.InvalidatingNullFinder.find_module * ...test.test_zipimport test of z.find_module * Suppress cross-references to find_loader and find_module * Suppress cross-references to Finder * Suppress cross-references to pkgutil.ImpImporter and pkgutil.ImpLoader --------- Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net> Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
* gh-91181: drop support for bytes on sys.path (GH-31934)Thomas Grainger2022-07-171-1/+2
| | | | | | Support for bytes broke sometime between Python 3.2 and 3.6 and has been broken ever since. Trying to bring back supports is surprisingly difficult in the face of -b and checking for keys in sys.path_importer_cache. Since the support was broken for so long, trying to overcome the difficulty of bringing back the support has been deemed not worth it. Co-authored-by: Eryk Sun <eryksun@gmail.com> Co-authored-by: Brett Cannon <brett@python.org>
* gh-94379: Remove zipimport find_loader() and find_module() methods (#94380)Victor Stinner2022-07-051-16/+0
| | | | | zipimport: Remove find_loader() and find_module() methods, deprecated in Python 3.10: use the find_spec() method instead. See PEP 451 for the rationale.
* gh-92886: Fix tests that fail when running with optimizations (`-O`) in ↵jackh-ncl2022-06-101-1/+4
| | | | `test_zipimport.py` (GH-93236)
* gh-90473: Decrease recursion limit and skip tests on WASI (GH-92803)Christian Heimes2022-05-191-0/+1
|
* bpo-46411: Remove unnecessary calls to sys.exc_info() in tests (GH-30638)Irit Katriel2022-01-181-2/+2
|
* bpo-45229: Remove test_main in many tests (GH-28405)Serhiy Storchaka2021-09-191-10/+4
| | | | | | | | | Instead of explicitly enumerate test classes for run_unittest() use the unittest ability to discover tests. This also makes these tests discoverable and runnable with unittest. load_tests() can be used for dynamic generating tests and adding doctests. setUpModule(), tearDownModule() and addModuleCleanup() can be used for running code before and after all module tests.
* bpo-45183: don't raise an exception when calling ↵Brett Cannon2021-09-171-1/+2
| | | | | zipimport.zipimporter.find_spec() when the zip file is missing and the internal cache has been reset (GH-28435) This can occur when the zip file gets deleted, you call zipimport.zipimporter.invalidate_cache(), and then try to use zipimport.zipimporter.find_spec() (i.e. you left the zip file path on sys.path).
* bpo-5846: Do not use obsolete unittest functions. (GH-28303)Serhiy Storchaka2021-09-131-1/+2
| | | | Get rid of use of makeSuite() and findTestCases(). Also make test_math and test_threading_local discoverable.
* bpo-34990: Treat the pyc header's mtime in compileall as an unsigned int ↵Ammar Askar2021-08-241-7/+10
| | | | | | (GH-19708) Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
* bpo-43950: Add option to opt-out of PEP-657 (GH-27023)Ammar Askar2021-07-071-0/+1
| | | | | Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
* bpo-43950: Print columns in tracebacks (PEP 657) (GH-26958)Ammar Askar2021-07-041-1/+4
| | | | | | | | The traceback.c and traceback.py mechanisms now utilize the newly added code.co_positions and PyCode_Addr2Location to print carets on the specific expressions involved in a traceback. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com> Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
* bpo-14678: Update zipimport to support importlib.invalidate_caches() (GH-24159)Desmond Cheong2021-03-081-0/+41
| | | Added an invalidate_caches() method to the zipimport.zipimporter class based on the implementation of importlib.FileFinder.invalidate_caches(). This was done by adding a get_files() method and an _archive_mtime attribute to zipimport.zipimporter to check for updates or cache invalidation whenever the cache of files and toc entry information in the zipimporter is accessed.
* bpo-24792: Fix zipimporter masking the cause of import errors (GH-22204)Irit Katriel2020-12-191-4/+4
| | | | | zipimport's _unmarshal_code swallows import errors and then _get_module_code doesn't know the cause of the error, and returns the generic, and sometimes incorrect, 'could not find...'. Automerge-Triggered-By: GH:brettcannon
* bpo-26131: Deprecate usage of load_module() (GH-23469)Brett Cannon2020-12-041-20/+31
| | | Raise an ImportWarning when the import system falls back on load_module(). As for implementations of load_module(), raise a DeprecationWarning.
* bpo-42131: Add PEP 451-related methods to zipimport (GH-23187)Brett Cannon2020-11-131-18/+53
| | | | | Specifically, find_spec(), create_module(), and exec_module(). Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
* bpo-40275: Use new test.support helper submodules in tests (GH-21412)Hai Shi2020-07-091-19/+21
|
* bpo-40275: More lazy imports in test.support (GH-20131)Hai Shi2020-05-181-1/+1
| | | | | | | | | | | | | | | | | | | Make the the following imports lazy in test.support: * bz2 * gzip * lzma * resource * zlib The following test.support decorators now need to be called with parenthesis: * @support.requires_bz2 * @support.requires_gzip * @support.requires_lzma * @support.requires_zlib For example, "@requires_zlib" becomes "@requires_zlib()".
* bpo-39033: Fix NameError in zipimport during hash validation (GH-17588)Xtreak2019-12-151-0/+16
| | | | Patch by Karthikeyan Singaravelan.
* bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929)Serhiy Storchaka2019-03-051-106/+92
|
* bpo-5950: Support reading zips with comments in zipimport (#9548)Zackery Spytz2018-09-251-0/+15
| | | * bpo-5950: Support reading zips with comments in zipimport
* bpo-25711: Remove outdated zipimport tests. (GH-9404)Serhiy Storchaka2018-09-191-49/+0
| | | They were specific to the C implementation.
* bpo-25711: Rewrite zipimport in pure Python. (GH-6809)Serhiy Storchaka2018-09-181-12/+17
|
* closes bpo-31650: PEP 552 (Deterministic pycs) implementation (#4575)Benjamin Peterson2017-12-091-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | Python now supports checking bytecode cache up-to-dateness with a hash of the source contents rather than volatile source metadata. See the PEP for details. While a fairly straightforward idea, quite a lot of code had to be modified due to the pervasiveness of pyc implementation details in the codebase. Changes in this commit include: - The core changes to importlib to understand how to read, validate, and regenerate hash-based pycs. - Support for generating hash-based pycs in py_compile and compileall. - Modifications to our siphash implementation to support passing a custom key. We then expose it to importlib through _imp. - Updates to all places in the interpreter, standard library, and tests that manually generate or parse pyc files to grok the new format. - Support in the interpreter command line code for long options like --check-hash-based-pycs. - Tests and documentation for all of the above.
* bpo-31781: Prevent crashes when calling methods of an uninitialized ↵Oren Milman2017-10-201-0/+14
| | | | zipimport.zipimporter object (GH-3986)
* bpo-31602: Fix an assertion failure in zipimporter.get_source() in case of a ↵Oren Milman2017-09-291-0/+17
| | | | | | | bad zlib.decompress() (GH-3784) While a rare potential failure (it requires swapping out zlib.decompress() itself and forcing it to return a non-bytes object), this change prevents a potential C-level assertion failure and instead substitutes it with an exception. Thanks to Oren Milman for the patch.
* bpo-31291: Fixed an assertion failure in zipimport.zipimporter.get_data() ↵Oren Milman2017-08-291-0/+17
| | | | | (#3226) if pathname.replace('/', '\\') returns non-string.
* Issue #28131: Merge from 3.5Berker Peksag2016-09-141-0/+13
|\
| * Issue #28131: Fix a regression in zipimport's compile_source()Berker Peksag2016-09-141-0/+13
| | | | | | | | zipimport should use the same optimization level as the interpreter.
* | Issue #25758: Prevents zipimport from unnecessarily encoding a filename ↵Steve Dower2016-09-101-1/+1
|\ \ | |/ | | | | (patch by Eryk Sun)
| * Issue #25758: Prevents zipimport from unnecessarily encoding a filename ↵Steve Dower2016-09-101-1/+1
| | | | | | | | (patch by Eryk Sun)
* | Issue #26754: Undocumented support of general bytes-like objectsSerhiy Storchaka2016-08-061-2/+4
| | | | | | | | as path in compile() and similar functions is now deprecated.
* | Issue #26754: PyUnicode_FSDecoder() accepted a filename argument encoded asSerhiy Storchaka2016-06-181-0/+15
|\ \ | |/ | | | | an iterable of integers. Now only strings and byte-like objects are accepted.
| * Issue #26754: PyUnicode_FSDecoder() accepted a filename argument encoded asSerhiy Storchaka2016-06-181-0/+15
| | | | | | | | an iterable of integers. Now only strings and byte-like objects are accepted.
* | Merge for issue #17633Brett Cannon2016-01-151-32/+216
|\ \ | |/
| * Issue #17633: Improve support for namespace packages with zipimport.Brett Cannon2016-01-151-32/+216
| | | | | | | | | | | | | | | | | | Previously zipimport mistakenly limited namespace support to only the top-level of the zipfile when it should have supported an arbitrary depth. Thanks to Phil Connel for the bug report and initial patch and Mike Romberg for the final patch.
* | Issue #8585: improved tests for zipimporter2. Patch from Mark Lawrence.Robert Collins2015-07-221-1/+20
|/
* Issue #23731: Implement PEP 488.Brett Cannon2015-04-131-1/+1
| | | | | | The concept of .pyo files no longer exists. Now .pyc files have an optional `opt-` tag which specifies if any extra optimizations beyond the peepholer were applied.
* Issue #23696: Remove test on ZipImportError.__context__ because the context isVictor Stinner2015-03-201-1/+0
| | | | | | | | | None on Windows. When the file is not readable, the error occurs at open on UNIX. On Windows, the error only occurs at the first operation on the open file. It would require to many changes to set __context__ to an OSError for all file operations, for a little benefit (__context__ is almost never used).
* Issue #23696: Chain ZipImportError to the OSErrorVictor Stinner2015-03-201-1/+4
|
* merge backout for #20621Benjamin Peterson2014-02-161-85/+19
|\
| * backout 2807a5f011e4 for causing #20621Benjamin Peterson2014-02-161-85/+19
| |
* | Fixes issue #19081: When a zipimport .zip file in sys.path being imported fromGregory P. Smith2014-01-081-19/+85
|\ \ | |/ | | | | | | | | is modified during the lifetime of the Python process after zipimport has already cached the zip's table of contents we detect this and recover rather than read bad data from the .zip (causing odd import errors).
| * Fixes Issue #19081: When a zipimport .zip file in sys.path being imported fromGregory P. Smith2014-01-081-19/+85
| | | | | | | | | | | | is modified during the lifetime of the Python process after zipimport has already cached the zip's table of contents we detect this and recover rather than read bad data from the .zip (causing odd import errors).
* | Issue 19572: More silently skipped tests explicitly skipped.Zachary Ware2013-12-081-1/+1
|\ \ | |/
| * Issue 19572: More silently skipped tests explicitly skipped.Zachary Ware2013-12-081-1/+1
| |
* | Issue #17177: Stop using imp in a bunch of testsBrett Cannon2013-06-151-3/+4
| |
* | Move code from test_importhooks into test_zipimport.Brett Cannon2013-06-121-1/+25
| |
* | Issue #8745: Small speed up zipimport on Windows. Patch by Catalin Iacob.Serhiy Storchaka2013-02-161-0/+2
| |
* | Replace IOError with OSError (#16715)Andrew Svetlov2012-12-251-1/+1
|/