summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
Commit message (Collapse)AuthorAgeFilesLines
* [3.12] GH-126606: don't write incomplete pyc files (GH-126627) (GH-126810)Miss Islington (bot)2024-11-131-1/+5
| | | | | | | | 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.12] gh-125519: Improve traceback if `importlib.reload()` is called with a ↵Miss Islington (bot)2024-10-211-1/+1
| | | | | | | | non-module object (GH-125520) (#125769) 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.12] gh-121735: Fix module-adjacent references in zip files (gh-123037) ↵Jason R. Coombs2024-09-241-2/+4
| | | | | | (#124011)
* [3.12] gh-117983: Defer import of threading for lazy module loading ↵Miss Islington (bot)2024-07-031-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-120233) (GH-121350) gh-117983: Defer import of threading for lazy module loading (GH-120233) As noted in gh-117983, the import importlib.util can be triggered at interpreter startup under some circumstances, so adding threading makes it a potentially obligatory load. Lazy loading is not used in the stdlib, so this removes an unnecessary load for the majority of users and slightly increases the cost of the first lazily loaded module. An obligatory threading load breaks gevent, which monkeypatches the stdlib. Although unsupported, there doesn't seem to be an offsetting benefit to breaking their use case. For reference, here are benchmarks for the current main branch: ``` ❯ hyperfine -w 8 './python -c "import importlib.util"' Benchmark 1: ./python -c "import importlib.util" Time (mean ± σ): 9.7 ms ± 0.7 ms [User: 7.7 ms, System: 1.8 ms] Range (min … max): 8.4 ms … 13.1 ms 313 runs ``` And with this patch: ``` ❯ hyperfine -w 8 './python -c "import importlib.util"' Benchmark 1: ./python -c "import importlib.util" Time (mean ± σ): 8.4 ms ± 0.7 ms [User: 6.8 ms, System: 1.4 ms] Range (min … max): 7.2 ms … 11.7 ms 352 runs ``` Compare to: ``` ❯ hyperfine -w 8 './python -c pass' Benchmark 1: ./python -c pass Time (mean ± σ): 7.6 ms ± 0.6 ms [User: 5.9 ms, System: 1.6 ms] Range (min … max): 6.7 ms … 11.3 ms 390 runs ``` This roughly halves the import time of importlib.util. (cherry picked from commit 94f50f8ee6872007d46c385f7af253497273255a) Co-authored-by: Chris Markiewicz <effigies@gmail.com>
* [3.12] gh-120910: Fix issue resolving relative paths outside site-packages. ↵Jason R. Coombs2024-06-231-1/+1
| | | | | | (GH-120911) (#120918) Incorporates changes from importlib_metadata 7.2.1. (cherry picked from commit 1ba0bb21ed4eb54023fdfccc9cb20be8fff946b1)
* [3.12] gh-117178: Recover lazy loading of self-referential modules ↵Miss Islington (bot)2024-03-281-6/+5
| | | | | | (GH-117179) (#117319) Co-authored-by: Chris Markiewicz <effigies@gmail.com>
* [3.12] gh-116811: Ensure MetadataPathFinder.invalidate_caches is reachable ↵Jason R. Coombs2024-03-152-0/+4
| | | | | | | | | | when delegated through PathFinder. (GH-116812) (#116864) * Make MetadataPathFinder a proper classmethod. * In PathFinder.invalidate_caches, also invoke MetadataPathFinder.invalidate_caches. * Add blurb (cherry picked from commit 5f52d20a93908196f74271db8437cc1ba7e1e262)
* [3.12] chore: fix typos (#116345) (#116370)Terry Jan Reedy2024-03-051-1/+1
| | | | Co-authored-by: cui fliter <imcusg@gmail.com> (cherry picked from commit e7ba6e9dbe5433b4a0bcb0658da6a68197c28630)
* [3.12] gh-114763: Protect lazy loading modules from attribute access races ↵Miss Islington (bot)2024-02-261-30/+51
| | | | | | | | | | (GH-114781) (GH-115870) gh-114763: Protect lazy loading modules from attribute access races (GH-114781) 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. (cherry picked from commit 200271c61db44d90759f8a8934949aefd72d5724) Co-authored-by: Chris Markiewicz <effigies@gmail.com>
* [3.12] Add missed `stream` argument (GH-111775) (#115716)Miss Islington (bot)2024-02-201-1/+1
| | | | | | | | | | Add missed `stream` argument (GH-111775) * Add missed `stream` argument * Add news (cherry picked from commit 1ff6c1416b0bb422f4847cd84fcb33662a2497ef) Co-authored-by: Alexander Shadchin <shadchin@yandex-team.com>
* [3.12] gh-112983: Add the known magic value of 3495 for Python 3.11 bytecode ↵Miss Islington (bot)2023-12-121-0/+1
| | | | | | | | | | (GH-112985) (#113023) gh-112983: Add the known magic value of 3495 for Python 3.11 bytecode (GH-112985) Add the known magic value of 3495 for Python 3.11 bytecode (cherry picked from commit 616622cab7200bac476bf753d6cc98f4ee48808c) Co-authored-by: wim glenn <jump@wimglenn.com>
* [3.12] gh-112414: Fix `AttributeError` when calling `repr()` on a namespace ↵Miss Islington (bot)2023-11-271-2/+8
| | | | | | | | package imported with a custom loader (GH-112425) (#112440) gh-112414: Fix `AttributeError` when calling `repr()` on a namespace package imported with a custom loader (GH-112425) (cherry picked from commit 0622839cfedacbb48eba27180fd0f0586fe97771) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* [3.12] GH-106176, GH-104702: Fix reference leak when importing across ↵Miss Islington (bot)2023-08-291-12/+103
| | | | | | | | multiple threads (GH-108497) (#108612) GH-106176, GH-104702: Fix reference leak when importing across multiple threads (GH-108497) (cherry picked from commit 5f85b443f7119e1c68a15fc9a342655e544d2852) Co-authored-by: Brett Cannon <brett@python.org>
* [3.12] gh-104310: Rename the New Function in importlib.util (gh-105255) ↵Miss Islington (bot)2023-06-081-5/+21
| | | | | | | | | | | | | | | | (gh-105518) The original name wasn't as clear as it could have been. This change includes the following: * rename the function * change the default value for "disable_check" to False * add clues to the docstring that folks should probably not use the function --------- (cherry picked from commit 34c63b86d3c33a85acf55a0c5c118304754e145d) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com> Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* gh-103763: Implement PEP 695 (#103764)Jelle Zijlstra2023-05-161-1/+2
| | | | | | | | | | | | | | This implements PEP 695, Type Parameter Syntax. It adds support for: - Generic functions (def func[T](): ...) - Generic classes (class X[T](): ...) - Type aliases (type X = ...) - New scoping when the new syntax is used within a class body - Compiler and interpreter changes to support the new syntax and scoping rules Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Eric Traut <eric@traut.com> Co-authored-by: Larry Hastings <larry@hastings.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-87729: improve hit rate of LOAD_SUPER_ATTR specialization (#104270)Carl Meyer2023-05-111-1/+2
|
* gh-97933: (PEP 709) inline list/dict/set comprehensions (#101441)Carl Meyer2023-05-091-1/+2
| | | | Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-104310: Add importlib.util.allowing_all_extensions() (gh-104311)Eric Snow2023-05-081-0/+37
| | | (I'll be adding docs for this separately.)
* gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059)Barry Warsaw2023-05-034-259/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-87729: specialize LOAD_SUPER_ATTR_METHOD (#103809)Carl Meyer2023-04-251-2/+3
|
* gh-87729: add LOAD_SUPER_ATTR instruction for faster super() (#103497)Carl Meyer2023-04-241-2/+3
| | | | | This speeds up `super()` (by around 85%, for a simple one-level `super().meth()` microbenchmark) by avoiding allocation of a new single-use `super()` object on each use.
* gh-103661: Apply bugfix from importlib_metadata 6.5.1 and restore test. ↵Jason R. Coombs2023-04-221-12/+14
| | | | (#103681)
* Sync with importlib_metadata 6.5 (GH-103584)Jason R. Coombs2023-04-213-20/+127
|
* Remove double space in import error message (#103458)Ned Batchelder2023-04-141-1/+1
|
* GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython ↵Mark Shannon2023-04-121-1/+2
| | | | | | | | | | (GH-103083) * The majority of the monitoring code is in instrumentation.c * The new instrumentation bytecodes are in bytecodes.c * legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
* GH-102700: allow built-in modules to be submodules (GH-103162)Brett Cannon2023-04-061-2/+0
|
* GH-88691: Shrink the CALL caches (GH-103230)Brandt Bucher2023-04-051-1/+2
|
* GH-89987: Shrink the BINARY_SUBSCR caches (GH-103022)Brandt Bucher2023-03-291-1/+3
|
* GH-100982: Break up COMPARE_AND_BRANCH (GH-102801)Brandt Bucher2023-03-231-2/+2
|
* gh-102859: Remove JUMP_IF_FALSE_OR_POP and JUMP_IF_TRUE_OR_POP (#102870)Irit Katriel2023-03-221-1/+2
|
* GH-90997: Shrink the LOAD_GLOBAL caches (#102569)Brandt Bucher2023-03-111-4/+9
|
* gh-102515: Remove unused imports in the `Lib/` directory (#102516)Alex Waygood2023-03-081-1/+0
|
* gh-97930: Apply changes from importlib_resources 5.12. (GH-102010)Jason R. Coombs2023-02-183-42/+67
|
* gh-101766: Fix refleak for _BlockingOnManager resources from test suite ↵Dong-hee Na2023-02-171-5/+0
| | | | level (gh-101988)
* gh-101766: Fix refleak for _BlockingOnManager resources (gh-101942)Dong-hee Na2023-02-171-0/+5
|
* gh-101799: implement PREP_RERAISE_STAR as an intrinsic function (#101800)Irit Katriel2023-02-141-1/+2
|
* GH-87849: Simplify stack effect of SEND and specialize it for generators and ↵Mark Shannon2023-02-131-1/+2
| | | | coroutines. (GH-101788)
* gh-101632: Add the new RETURN_CONST opcode (#101633)penguin_wwy2023-02-071-1/+2
|
* Fix incorrect versions in magic number comments (GH-101301)Brandt Bucher2023-01-251-8/+8
|
* GH-100762: Don't call `gen.throw()` in `gen.close()`, unless necessary. ↵Mark Shannon2023-01-241-2/+3
| | | | | | (GH-101013) * Store exception stack depth in YIELD_VALUE's oparg and use it avoid expensive gen.throw() in gen.close() where possible.
* gh-91351: Fix some bugs in importlib handling of re-entrant imports (GH-94504)Jean-Paul Calderone2023-01-211-37/+196
| | | Co-authored-by: Brett Cannon <brett@python.org>
* GH-100982: Add `COMPARE_AND_BRANCH` instruction (GH-100983)Mark Shannon2023-01-161-1/+2
|
* GH-100923: Embed jump mask in `COMPARE_OP` oparg (GH-100924)Mark Shannon2023-01-111-1/+2
|
* GH-99005: More intrinsics (GH-100774)Mark Shannon2023-01-061-1/+2
| | | * Remove UNARY_POSITIVE, LIST_TO_TUPLE and ASYNC_GEN_WRAP, replacing them with intrinsics.
* GH-99005: Add `CALL_INTRINSIC_1` instruction (GH-100771)Mark Shannon2023-01-051-1/+2
| | | | | | | | * Remove PRINT_EXPR instruction * Remove STOPITERATION_ERROR instruction * Remove IMPORT_STAR instruction
* gh-97930: Apply changes from importlib_resources 5.10. (GH-100598)Jason R. Coombs2023-01-014-57/+100
|
* gh-100585: Fixed a bug where importlib.resources.as_file was leaving file ↵Samet YASLAN2022-12-281-1/+1
| | | | | | | pointers open (GH-100586) * gh-100585: Fixed open fp bug in the imporlib module * Added news for gh-100585
* closes gh-99508: fix `TypeError` in `Lib/importlib/_bootstrap_external.py` ↵Nikita Sobolev2022-11-231-1/+2
| | | | (GH-99635)
* gh-99254: remove all unused consts from code objects (GH-99255)Irit Katriel2022-11-111-1/+2
|
* gh-98139: enhance namespace package reprAnh71me2022-11-061-1/+1
|