summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib
Commit message (Collapse)AuthorAgeFilesLines
* [3.7] bpo-39769: Fix compileall ddir for subpkgs. (GH-18676) (GH-18718) ↵Gregory P. Smith2020-03-011-0/+11
| | | | | | | | | | | | | | | | | | | | | | (GH-18725) Fix compileall.compile_dir() ddir= behavior on sub-packages. Fixes compileall.compile_dir's ddir parameter and compileall command line flag `-d` to no longer write the wrong pathname to the generated pyc file for submodules beneath the root of the directory tree being compiled. This fixes a regression introduced with Python 3.5. Tests backported from GH 02673352b5db6ca4d3dc804965facbedfe66425d, the implementation is different due to intervening code changes. But still quiet simple. Why was the bug ever introduced? The refactoring to add parallel execution kept the ddir -> dfile computations but discarded the results instead of sending them to compile_file(). This fixes that. Lack of tests meant this went unnoticed.. (cherry picked from commit ce720d3e0674d6ac6f1b950c20a89be4cfde7853) Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google]
* Fix typo in test_api.py. (GH-16119)Miss Islington (bot)2019-09-131-1/+1
| | | | | (cherry picked from commit 0bc17ea2f5966f429b5b8d6b4ccb9c01f1f610d0) Co-authored-by: Benjamin Peterson <benjamin@python.org>
* Revert "Remove unused imports in tests (GH-14518) (GH-14522)" (GH-14555)Victor Stinner2019-07-021-0/+1
| | | This reverts commit e34b5f4d6483187969d5149c801d056b72ef2ddb.
* Remove unused imports in tests (GH-14518) (GH-14522)Victor Stinner2019-07-011-1/+0
| | | (cherry picked from commit 8f4ef3b019ce380022018587571b0f970e668de3)
* [3.7] bpo-36766: Typos in docs and code comments (GH-13116). (GH-13136)penguindustin2019-05-061-1/+1
| | | | | | | | | | | (cherry picked from commit 964663089547ca110199e23867b46b07ff4be88c) Co-authored-by: penguindustin <penguindustin@gmail.com> https://bugs.python.org/issue36766
* bpo-34022: Stop forcing of hash-based invalidation with SOURCE_DATE_EPOCH ↵Miss Islington (bot)2018-11-281-0/+15
| | | | | | | | | | | | | | | | | | | | | | | (GH-9607) Unconditional forcing of ``CHECKED_HASH`` invalidation was introduced in 3.7.0 in bpo-29708. The change is bad, as it unconditionally overrides *invalidation_mode*, even if it was passed as an explicit argument to ``py_compile.compile()`` or ``compileall``. An environment variable should *never* override an explicit argument to a library function. That change leads to multiple test failures if the ``SOURCE_DATE_EPOCH`` environment variable is set. This changes ``py_compile.compile()`` to only look at ``SOURCE_DATE_EPOCH`` if no explicit *invalidation_mode* was specified. I also made various relevant tests run with explicit control over the value of ``SOURCE_DATE_EPOCH``. While looking at this, I noticed that ``zipimport`` does not work with hash-based .pycs _at all_, though I left the fixes for subsequent commits. (cherry picked from commit a6b3ec5b6d4f6387820fccc570eea08b9615620d) Co-authored-by: Elvis Pranskevichus <elvis@magic.io>
* Sync the importlib magic number in test_importlib for 3.7.0Ned Deily2018-06-271-1/+1
|
* bpo-29514: Make magic number test work for candidatesNed Deily2018-06-271-1/+1
|
* bpo-33755: Fix importlib.resources isolation tests (GH-7412) (#7434)Miss Islington (bot)2018-06-052-1/+9
| | | | | (cherry picked from commit ac1ee1badade69d5cd6d8b9112281f121183e7c0) Co-authored-by: Barry Warsaw <barry@python.org>
* bpo-32374: Ignore Python-level exceptions in test_bad_traverse (GH-7145) ↵Miss Islington (bot)2018-05-281-7/+13
| | | | | | | (GH-7150) (cherry picked from commit 08c5aca9d13b24b35faf89ebd26fc348ae1731b2) Co-authored-by: Marcel Plch <gmarcel.plch@gmail.com>
* bpo-33629: Prevent coredump in test_importlib (GH-7090)Miss Islington (bot)2018-05-241-1/+4
| | | | | | | | bpo-32374, bpo-33629: Use support.SuppressCrashReport() in test_bad_traverse() of MultiPhaseExtensionModuleTests to prevent leaking a core dump file. (cherry picked from commit 483000e164ec68717d335767b223ae31b4b720cf) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-33254: do not return an empty list when asking for the contents of a ↵Miss Islington (bot)2018-04-301-4/+3
| | | | | | | namespace package (GH-6467) (cherry picked from commit 3ab9365dca8438f89b2060cd3eebe00606133dc4) Co-authored-by: Brett Cannon <brettcannon@users.noreply.github.com>
* [3.7] bpo-33169: Remove values of `None` from sys.path_importer_cache when ↵Brett Cannon2018-04-072-1/+22
| | | | | | invalidating caches (GH-6402) (GH-6403) An entry of None in sys.path_importer_cache represents a negative/missing finder for a path, so clearing it out makes sense. (cherry picked from commit 9e2be60634914f23db2ae5624e4acc9335bf5fea)
* bpo-33151: Handle submodule resources (GH-6268) (GH-6270)Miss Islington (bot)2018-03-272-3/+32
| | | | | (cherry picked from commit 30e507dff465a31901d87df791a2bac40dc88530) Co-authored-by: Barry Warsaw <barry@python.org>
* bpo-32374: m_traverse may be called with m_state=NULL (GH-5140)Miss Islington (bot)2018-03-171-1/+15
| | | | | | | | Multi-phase initialized modules allow m_traverse to be called while the module is still being initialized, so module authors may need to account for that. (cherry picked from commit c2b0b12d1a137ada1023ab7c10b8d9a0249d95f9) Co-authored-by: Marcel Plch <gmarcel.plch@gmail.com>
* bpo-32303 - Consistency fixes for namespace loaders (GH-5481) (#5503)Barry Warsaw2018-02-032-2/+20
| | | | | | | | | | * Make sure ``__spec__.loader`` matches ``__loader__`` for namespace packages. * Make sure ``__spec__.origin` matches ``__file__`` for namespace packages. https://bugs.python.org/issue32303 https://bugs.python.org/issue32305 (cherry picked from commit bbbcf8693b876daae4469765aa62f8924f39a7d2) Co-authored-by: Barry Warsaw <barry@python.org>
* bpo-32248: Fix test_importlib.test_open() (#5213)Victor Stinner2018-01-171-2/+2
| | | | Use the binary.file instead of utf-8.file to avoid issues with Unix newlines vs Windows newlines.
* Implement the get_resource_reader() API for file system imports (#5168)Barry Warsaw2018-01-152-1/+4
|
* bpo-32248 - Implement importlib.resources (#4911)Barry Warsaw2017-12-3024-0/+473
| | | | Port importlib_resources to importlib.resources
* bpo-32248: Implement importlib.abc.ResourceReader (GH-4892)Brett Cannon2017-12-161-0/+39
|
* bpo-32297: Few misspellings found in Python source code comments. (#4803)Mike2017-12-142-2/+2
| | | | | | | | * Fix multiple typos in code comments * Add spacing in comments (test_logging.py, test_math.py) * Fix spaces at the beginning of comments in test_logging.py
* closes bpo-31650: PEP 552 (Deterministic pycs) implementation (#4575)Benjamin Peterson2017-12-092-15/+197
| | | | | | | | | | | | | | | | | | | | | | | | | 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-21720: Restore the Python 2.7 logic in handling a fromlist. (#4118)Serhiy Storchaka2017-10-261-0/+43
| | | | | | BytesWarning no longer emitted when the fromlist argument of __import__() or the __all__ attribute of the module contain bytes instances.
* bpo-31642: Restore blocking "from" import by setting None in sys.modules. ↵Serhiy Storchaka2017-10-081-0/+14
| | | | (#3834)
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-122/+100
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* Spelling fixes (#2902)Ville Skyttä2017-08-031-1/+1
|
* bpo-30876: Relative import from unloaded package now reimports the package ↵Serhiy Storchaka2017-07-121-1/+1
| | | | | | | | | (#2639) instead of failing with SystemError. Relative import from non-package now fails with ImportError rather than SystemError.
* bpo-30436: Raise ModuleNotFoundError for importlib.util.find_spec() when ↵Milan Oberkirch2017-06-141-0/+6
| | | | | parent isn't a package (GH-1899) Previously AttributeError was raised, but that's not very reflective of the fact that the requested module can't be found since the specified parent isn't actually a package.
* bpo-29851: Have importlib.reload() raise ImportError if the module's spec is ↵Garvit Khatri2017-05-241-2/+12
| | | | not found (GH-972)
* bpo-30158: Fix deprecation warnings in test_importlib introduced by ↵Serhiy Storchaka2017-04-291-13/+16
| | | | bpo-29576. (#1285)
* bpo-29514: Check magic number for bugfix release (#54)Eric Appelt2017-04-171-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bpo-29514: Check magic number for micro release Add a dict importlib.util.EXPECTED_MAGIC_NUMBERS which details the initial and expected pyc magic number for each minor release. This gives a mechanism for users to check if the magic number has changed within a release and for a test to ensure procedure is followed if a change is necessary. Add a test to check the current MAGIC_NUMBER against the expected number for the release if the current release is at candidate or final level. On test failure, describe to the developer the procedure for changing the magic number. * Simplify magic number release test Simplify the magic number release test by removing EXPECTED_MAGIC_NUMBERS table and making the expected magic number self-contained within the test. BPO: 29514 * Improve magic number test execution and message Improve the execution of the magic number test by using skipUnless for alpha and beta releases, and directly inheriting from unittest.TestCase rather than using the machinery for the other tests. Also improve the error message to explain the reason for caution in changing the magic number. BPO: 29514
* bpo-29576: add explicit deprecation for importlib.abc.find_loader() and ↵Matthias Bussonnier2017-02-161-0/+6
| | | | | | find_module() (GH-32)
* Remove unused imports.Serhiy Storchaka2016-12-162-3/+0
|
* Issue #26940: Fix test_importlib that hangs on the Android armv7 qemu emulator.Xavier de Gaye2016-12-081-1/+1
|
* Issue #28026: Raise ImportError when exec_module() exists but ↵Eric Snow2016-09-081-7/+1
| | | | create_module() is missing.
* Issue #26667: Add path-like object support to importlib.util.Brett Cannon2016-09-082-0/+25
|
* Issue #15767: Use ModuleNotFoundError.Eric Snow2016-09-072-5/+9
|
* Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-301-1/+1
|
* Merge #27782 fix from 3.5Nick Coghlan2016-08-211-0/+9
|\
| * Issue #27782: Fix m_methods handling in multiphase initNick Coghlan2016-08-211-0/+9
| | | | | | | | | | | | | | | | Multi-phase extension module import now correctly allows the ``m_methods`` field to be used to add module level functions to instances of non-module types returned from ``Py_create_mod``. Patch by Xiang Zhang.
* | Merge for #27083Brett Cannon2016-07-163-18/+18
|\ \ | |/
| * Fix regressions introduced by fixes for issue #27083.Brett Cannon2016-07-163-18/+18
| |
* | Merge for #27083Brett Cannon2016-07-151-6/+9
|\ \ | |/
| * Issue #27083: Respect the PYTHONCASEOK environment variable underBrett Cannon2016-07-151-6/+9
| | | | | | | | | | | | | | | | | | | | Windows. Originally only b'PYTHONCASEOK' was being checked for in os.environ, but that won't work under Windows where all environment variables are strings (on OS X they are bytes). Thanks to Eryk Sun for the bug report.
* | Issue #26896: Disambiguate uses of "importer" with "finder".Brett Cannon2016-07-082-2/+0
| | | | | | | | Thanks to Oren Milman for the patch.
* | Issue #26186: Remove the restriction that built-in and extensionBrett Cannon2016-06-251-0/+2
| | | | | | | | | | | | | | | | modules can't be lazily loaded. Thanks to Python 3.6 allowing for types.ModuleType to have its __class__ mutated, the restriction can be lifted by calling create_module() on the wrapped loader.
* | Merge from 3.5Brett Cannon2016-06-251-3/+13
|\ \ | |/
| * Fix a scoping issue where an UnboundLocalError was triggered if aBrett Cannon2016-06-251-3/+13
| | | | | | | | lazy-loaded module was already in sys.modules.
* | Issue #21099: Switch applicable importlib tests to use PEP 451 API.Eric Snow2016-05-107-38/+106
| |
* | Fixes #19711: Add tests for reloading namespace packages.Eric Snow2016-05-101-1/+33
| |