summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-82916: Don't fail when importing from / with sys.pycache_prefix ↵Miss Islington (bot)2025-09-181-0/+12
| | | | | | | | set (GH-30456) (GH-137905) (cherry picked from commit d8a9466e29f59f81aacf1959b835862bcd47b731) Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] gh-123085: _compile_importlib: Avoid copying sources before ↵Miss Islington (bot)2025-08-181-8/+7
| | | | | | | | | compilation (GH-124131) (#137914) gh-123085: _compile_importlib: Avoid copying sources before compilation (GH-124131) (cherry picked from commit 42c8b0556c02d29e32f4c7c95e7128a343716250) Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* [3.13] gh-123085: Fix issue in inferred caller when resource package has no ↵Jason R. Coombs2025-08-151-2/+37
| | | | source (GH-123102) (#124024)
* [3.13] gh-134100: Fix use-after-free in `PyImport_ImportModuleLevelObject` ↵Miss Islington (bot)2025-05-181-0/+15
| | | | | | | | (GH-134117) (#134172) gh-134100: Fix use-after-free in `PyImport_ImportModuleLevelObject` (GH-134117) (cherry picked from commit 4e9005d32ff466925f40af410f2ea6bf2329bcf8) Co-authored-by: Nico-Posada <102486290+Nico-Posada@users.noreply.github.com>
* [3.13] gh-133454: Mark tests with many threads that use much memory as ↵Miss Islington (bot)2025-05-081-5/+10
| | | | | | | bigmem (GH-133456) (GH-133664) (cherry picked from commit 26839eae2079bd797491dfdcc00eaca1dbcbf77c) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] gh-71339: Use new assertion methods in test_import and test_importlib ↵Serhiy Storchaka2025-04-0818-52/+55
| | | | | | | | (GH-129052) (#129123) (cherry picked from commit f7cc7d296c2cbb33d3f0bde4ace82e8569f7dbc3) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] gh-123987: Fix NotADirectoryError in NamespaceReader when sentinel ↵Miss Islington (bot)2025-01-262-7/+65
| | | | | | | | present (GH-124018) (#129319) gh-123987: Fix NotADirectoryError in NamespaceReader when sentinel present (GH-124018) (cherry picked from commit b543b32eff78ce214e68e8c5fc15a8c843fa8dec) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* [3.13] gh-71339: Add additional assertion methods in test.support ↵Serhiy Storchaka2025-01-201-7/+2
| | | | | | | | | | | | (GH-128707) (GH-128815) Add a mix-in class ExtraAssertions containing the following methods: * assertHasAttr() and assertNotHasAttr() * assertIsSubclass() and assertNotIsSubclass() * assertStartsWith() and assertNotStartsWith() * assertEndsWith() and assertNotEndsWith() (cherry picked from commit 06cad77a5b345adde88609be9c3c470c5cd9f417)
* [3.13] GH-126606: don't write incomplete pyc files (GH-126627) (GH-126809)Miss Islington (bot)2024-11-131-0/+32
| | | | | | | | GH-126606: don't write incomplete pyc files (GH-126627) (cherry picked from commit c695e37a3f95c225ee08d1e882d23fa200b5ec34) Co-authored-by: CF Bolz-Tereick <cfbolz@gmx.de> Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru> Co-authored-by: Brett Cannon <brett@python.org>
* [3.13] gh-125519: Improve traceback if `importlib.reload()` is called with a ↵Miss Islington (bot)2024-10-211-0/+16
| | | | | | | | non-module object (GH-125520) (#125768) gh-125519: Improve traceback if `importlib.reload()` is called with a non-module object (GH-125520) (cherry picked from commit c5c21fee7ae1ea689a351caa454c98e716a6e537) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* [3.13] gh-121735: Fix module-adjacent references in zip files (GH-123037) ↵Miss Islington (bot)2024-09-3035-232/+214
| | | | | | | | | | | | | | | | | | | | | | | | | | (#123986) * gh-121735: Fix module-adjacent references in zip files (GH-123037) * gh-116608: Apply style and compatibility changes from importlib_metadata. * gh-121735: Ensure module-adjacent resources are loadable from a zipfile. * gh-121735: Allow all modules to be processed by the ZipReader. * Add blurb * Remove update-zips script, unneeded. * Remove unnecessary references to removed static fixtures. * Remove zipdata fixtures, unused. (cherry picked from commit ba687d9481c04fd160795ff8d8568f5c9f877128) * gh-123994: Generate utf-16 file using little endian and BOM. (#123995) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* [3.13] gh-116608: Apply style and compatibility changes from ↵Miss Islington (bot)2024-08-151-31/+49
| | | | | | | | importlib_resources. (GH-123028) (#123051) gh-116608: Apply style and compatibility changes from importlib_metadata. (GH-123028) (cherry picked from commit e913d2c87f1ae4e7a4aef5ba78368ef31d060767) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* [3.13] Update the expected bytecode magic number in test_importlib.test_util ↵T. Wouters2024-07-311-1/+1
| | | | | (#122513) Update the expected bytecode magic number in test_importlib.test_util.
* [3.13] gh-121279: Fix importlib DeprecatedAttrsTests (#121319)Victor Stinner2024-07-031-0/+3
| | | | | Delete attributes after getting them, so the warning is emitted again when the test is run multiple times (ex: when checking for reference leaks).
* [3.13] gh-121279: Re-add prematurely removed import warnings to ↵Miro Hrončok2024-07-031-0/+22
| | | | | | | importlib.abc (#121281) Fixup for 51724620e868512bbedb1547aca441bcd27bbe0c Fixes https://github.com/python/cpython/issues/121279
* [3.13] gh-120910: Fix issue resolving relative paths outside site-packages. ↵Miss Islington (bot)2024-06-232-0/+35
| | | | | | | | | | (GH-120911) (#120917) gh-120910: Fix issue resolving relative paths outside site-packages. (GH-120911) Incorporates changes from importlib_metadata 7.2.1. (cherry picked from commit 1ba0bb21ed4eb54023fdfccc9cb20be8fff946b1) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* [3.13] gh-106531: Apply changes from importlib_resources 6.3.2 (GH-117054) ↵Miss Islington (bot)2024-06-0412-144/+170
| | | | | | | | | | (#120014) gh-106531: Apply changes from importlib_resources 6.3.2 (GH-117054) Apply changes from importlib_resources 6.3.2. (cherry picked from commit 8d63c8d47b9edd8ac2f0b395b2fa0ae5f571252d) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* [3.13] gh-118727: Don't drop the GIL in `drop_gil()` unless the current ↵Miss Islington (bot)2024-05-231-4/+1
| | | | | | | | | | | | | | | | | | | | thread holds it (GH-118745) (#119474) `drop_gil()` assumes that its caller is attached, which means that the current thread holds the GIL if and only if the GIL is enabled, and the enabled-state of the GIL won't change. This isn't true, though, because `detach_thread()` calls `_PyEval_ReleaseLock()` after detaching and `_PyThreadState_DeleteCurrent()` calls it after removing the current thread from consideration for stop-the-world requests (effectively detaching it). Fix this by remembering whether or not a thread acquired the GIL when it last attached, in `PyThreadState._status.holds_gil`, and check this in `drop_gil()` instead of `gil->enabled`. This fixes a crash in `test_multiprocessing_pool_circular_import()`, so I've reenabled it. (cherry picked from commit be1dfccdf2c5c7671b8a549e969b8cf7d60d9936) Co-authored-by: Brett Simmers <swtaarrs@users.noreply.github.com>
* gh-118729: Temporarily skip `test_multiprocessing_pool_circular_import` ↵Sam Gross2024-05-071-1/+4
| | | | | | | (#118732) The `pool_in_threads.py` test file may crash in free-threaded builds, which can lead to the Tsan test hanging. Skip it for now until we fix the underlying issue.
* gh-116322: Add Py_mod_gil module slot (#116882)Brett Simmers2024-05-032-24/+55
| | | | | | | | | | | | | | This PR adds the ability to enable the GIL if it was disabled at interpreter startup, and modifies the multi-phase module initialization path to enable the GIL when loading a module, unless that module's spec includes a slot indicating it can run safely without the GIL. PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148. A warning will be issued up to once per interpreter for the first GIL-using module that is loaded. If `-v` is given, a shorter message will be printed to stderr every time a GIL-using module is loaded (including the first one that issues a warning).
* gh-76785: Rename _xxsubinterpreters to _interpreters (gh-117791)Eric Snow2024-04-241-1/+1
| | | See https://discuss.python.org/t/pep-734-multiple-interpreters-in-the-stdlib/41147/26.
* gh-117649: Raise ImportError for unsupported modules in free-threaded build ↵Sam Gross2024-04-111-0/+4
| | | | | | | | | | (#117651) The free-threaded build does not currently support the combination of single-phase init modules and non-isolated subinterpreters. Ensure that `check_multi_interp_extensions` is always `True` for subinterpreters in the free-threaded build so that importing these modules raises an `ImportError`.
* gh-117182: Allow lazily loaded modules to modify their own __class__Chris Markiewicz2024-04-091-0/+28
|
* gh-116622: Test updates for Android (#117299)Malcolm Smith2024-04-051-1/+2
| | | | | | | - re-enable test_fcntl_64_bit on Linux aarch64, but disable it on all Android ABIs - use support.setswitchinterval in all relevant tests - skip test_fma_zero_result on Android x86_64 - accept EACCES when calling os.get_terminal_size on Android
* gh-116608: Ignore UTF-16 BOM in importlib.resources._functional tests ↵Petr Viktorin2024-04-051-4/+10
| | | | | | | | | | | | | (GH-117569) gh-116609: Ignore UTF-16 BOM in importlib.resources._functional tests To test the `errors` argument, we read a UTF-16 file as UTF-8 with "backslashreplace" error handling. However, the utf-16 codec adds an endian-specific byte-order mark, so on big-endian machines the expectation doesn't match the test file (which was saved on a little-endian machine). Use endswith to ignore the BOM.
* gh-116608: importlib.resources: Un-deprecate functional API & add ↵Petr Viktorin2024-04-051-0/+219
| | | | subdirectory support (GH-116609)
* gh-116303: Skip test module dependent tests if test modules are unavailable ↵Erlend E. Aasland2024-04-031-0/+2
| | | | (#117341)
* gh-76785: Consolidate Some Interpreter-related Testing Helpers (gh-117485)Eric Snow2024-04-021-2/+2
| | | This eliminates the duplication of functionally identical helpers in the _testinternalcapi and _xxsubinterpreters modules.
* gh-117178: Recover lazy loading of self-referential modules (#117179)Chris Markiewicz2024-03-281-0/+18
|
* gh-117089: Apply changes from importlib_metadata 7.1.0 (#117094)Jason R. Coombs2024-03-217-39/+56
| | | | | * Apply changes from importlib_metadata 7.1.0 * Include the data sources in the makefile (even though they're not needed)
* gh-117089: Move importlib.metadata tests to their own package (#117092)Jason R. Coombs2024-03-2012-1/+3
| | | | | | | | | * Ensure importlib.metadata tests do not leak references in sys.modules. * Move importlib.metadata tests to their own package for easier syncing with importlib_metadata. * Update owners and makefile for new directories. * Add blurb
* gh-114099 - Add iOS framework loading machinery. (GH-116454)Russell Keith-Magee2024-03-194-24/+74
| | | | Co-authored-by: Malcolm Smith <smith@chaquo.com> Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* GH-115979: update test_importlib to work under WASI SDK 21 (GH-116754)Brett Cannon2024-03-137-28/+44
|
* gh-116307: Proper fix for 'mod' leaking across importlib tests (#116680)Jason R. Coombs2024-03-121-1/+1
| | | gh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
* gh-114763: Protect lazy loading modules from attribute access races (GH-114781)Chris Markiewicz2024-02-241-2/+40
| | | Setting the __class__ attribute of a lazy-loading module to ModuleType enables other threads to attempt to access attributes before the loading is complete. Now that is protected by a lock.
* gh-114107: Fix importlib.resources symlink test if symlinks aren't supported ↵Petr Viktorin2024-01-161-0/+2
| | | | | (#114108) gh-114107: Fix symlink test if symlinks aren't supported
* gh-81682: Fix test failures when CPython is built without docstrings (GH-113410)Serhiy Storchaka2023-12-231-1/+3
|
* gh-113174: Sync with importlib_metadata 7.0 (#113175)Jason R. Coombs2023-12-213-56/+106
| | | | | | | | | | | | | | | | | | | | | | | * Sync with importlib_metadata 7.0.0 * Add blurb * Update docs to reflect changes. * Link datamodel docs for object.__getitem__ Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> * Add what's new for removed __getattr__ * Link datamodel docs for object.__getitem__ Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> * Add exclamation point, as that seems to be used for other classes. --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-76785: Fixes for test.support.interpreters (gh-112982)Eric Snow2023-12-121-2/+14
| | | This involves a number of changes for PEP 734.
* gh-112535: Add test on _Py_ThreadId() (#112709)Victor Stinner2023-12-041-2/+2
| | | Add also test.support.Py_GIL_DISABLED constant.
* gh-112414: Add additional unit tests for calling `repr()` on a namespace ↵Alex Waygood2023-11-281-4/+0
| | | | | package (#112475) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* gh-112414: Fix `AttributeError` when calling `repr()` on a namespace package ↵Alex Waygood2023-11-272-1/+5
| | | | imported with a custom loader (#112425)
* gh-76785: Return an "excinfo" Object From Interpreter.run() (gh-111573)Eric Snow2023-11-231-14/+8
|
* gh-111863: Rename `Py_NOGIL` to `Py_GIL_DISABLED` (#111864)Hugo van Kemenade2023-11-201-1/+1
| | | Rename Py_NOGIL to Py_GIL_DISABLED
* gh-110119: Fix test_importlib `--disable-gil` Windows test failures (#110422)Sam Gross2023-10-051-2/+5
| | | Use "t" in the expected tag for `--disable-gil` builds in test_tagged_suffix.
* gh-109974: Fix more threading lock_tests race conditions (#110089)Victor Stinner2023-09-291-1/+2
| | | | | | | | | * Add context manager on Bunch class. * Bunch now catchs exceptions on executed functions and re-raise them at __exit__() as an ExceptionGroup. * Rewrite BarrierProxy.test_default_timeout(). Use a single thread. Only check that barrier.wait() blocks for at least default timeout seconds. * test_with(): inline _with() function.
* gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (#109629)Antoine Pitrou2023-09-261-0/+2
| | | | | --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-109653: Remove unused imports in the `Lib/` directory (#109803)Alex Waygood2023-09-241-1/+0
|
* gh-105873: Make `_xxsubinterpreters` use exception type name in shared ↵Radislav Chugunov2023-07-081-1/+1
| | | | exception (#105874)
* gh-106300: Improve `assertRaises(Exception)` usages in tests (GH-106302)Nikita Sobolev2023-07-071-1/+1
|