summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-97850: Update the deprecation warning of ↵Miss Islington (bot)2025-02-111-1/+1
| | | | | | | | `importlib.abc.Loader.load_module` (GH-129855) (GH-130013) gh-97850: Update the deprecation warning of `importlib.abc.Loader.load_module` (GH-129855) (cherry picked from commit aa81a6f6e4f265565da9781d0bf95c7d16ddd961) Co-authored-by: Tomas R <tomas.roun8@gmail.com>
* [3.13] gh-123987: Fix NotADirectoryError in NamespaceReader when sentinel ↵Miss Islington (bot)2025-01-264-10/+24
| | | | | | | | 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-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952) ↵Miss Islington (bot)2024-12-031-8/+8
| | | | | | | | | | | (#122984) gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952) As of 529a160 (gh-118204), building with HAVE_DYNAMIC_LOADING stopped working. This is a minimal fix just to get builds working again. There are actually a number of long-standing deficiencies with HAVE_DYNAMIC_LOADING builds that need to be resolved separately. (cherry picked from commit ee1b8ce26e700350e47a5f65201097121c41912e) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* [3.13] GH-126606: don't write incomplete pyc files (GH-126627) (GH-126809)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.13] gh-125519: Improve traceback if `importlib.reload()` is called with a ↵Miss Islington (bot)2024-10-211-1/+1
| | | | | | | | 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-301-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | (#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-5/+1
| | | | | | | | 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] gh-117983: Defer import of threading for lazy module loading ↵Miss Islington (bot)2024-07-031-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-120233) (GH-121349) 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.13] gh-121279: Re-add prematurely removed import warnings to ↵Miro Hrončok2024-07-031-0/+1
| | | | | | | 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-231-1/+1
| | | | | | | | | | (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-120417: Remove unused imports in the stdlib (GH-120420) (#120429)Miss Islington (bot)2024-06-121-1/+0
| | | | | | gh-120417: Remove unused imports in the stdlib (GH-120420) (cherry picked from commit 4c6d4f5cb33e48519922d635894eef356faddba2) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-106531: Apply changes from importlib_resources 6.3.2 (GH-117054) ↵Miss Islington (bot)2024-06-042-2/+54
| | | | | | | | | | (#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-119311: Fix name mangling with PEP 695 generic classes (#119464) ↵Jelle Zijlstra2024-05-281-1/+2
| | | | | | | | (#119643) Fixes #119311. Fixes #119395. (cherry picked from commit a9a74da4a0ca0645f049e67b6434a95e30592c32)
* Fix typo inaccuracy in _bootstrap_external.py (GH-118619)wim glenn2024-05-071-1/+1
|
* gh-118465: Add __firstlineno__ attribute to class (GH-118475)Serhiy Storchaka2024-05-061-1/+2
| | | | It is set by compiler with the line number of the first line of the class definition.
* fix comment typo in importlib (#118567)wim glenn2024-05-041-1/+1
|
* gh-117182: Allow lazily loaded modules to modify their own __class__Chris Markiewicz2024-04-091-4/+8
|
* gh-116608: importlib.resources: Un-deprecate functional API & add ↵Petr Viktorin2024-04-052-0/+102
| | | | subdirectory support (GH-116609)
* gh-117178: Recover lazy loading of self-referential modules (#117179)Chris Markiewicz2024-03-281-6/+5
|
* gh-89739: gh-77140: Support zip64 in zipimport (GH-94146)Tim Hatch2024-03-281-0/+5
| | | | | | | | | | | | | | | * Reads zip64 files as produced by the zipfile module * Include tests (somewhat slow, however, because of the need to create "large" zips) * About the same amount of strictness reading invalid zip files as zipfile has * Still works on files with prepended data (like pex) There are a lot more test cases at https://github.com/thatch/zipimport64/ that give me confidence that this works for real-world files. Fixes #89739 and #77140. --------- Co-authored-by: Itamar Ostricher <itamarost@gmail.com> Reviewed-by: Gregory P. Smith <greg@krypto.org>
* GH-109653: Defer import of ``importlib.metadata._adapters`` (#109829)Adam Turner2024-03-212-3/+7
| | | | | | | | | | | * adapters * Add comments for deferred imports with links to rationale. * Add blurb --------- Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* gh-117089: Apply changes from importlib_metadata 7.1.0 (#117094)Jason R. Coombs2024-03-212-56/+151
| | | | | * Apply changes from importlib_metadata 7.1.0 * Include the data sources in the makefile (even though they're not needed)
* gh-114099 - Add iOS framework loading machinery. (GH-116454)Russell Keith-Magee2024-03-193-4/+56
| | | | Co-authored-by: Malcolm Smith <smith@chaquo.com> Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* gh-116811: Ensure MetadataPathFinder.invalidate_caches is reachable when ↵Jason R. Coombs2024-03-142-0/+4
| | | | | | | | | delegated through PathFinder. (#116812) * Make MetadataPathFinder a proper classmethod. * In PathFinder.invalidate_caches, also invoke MetadataPathFinder.invalidate_caches. * Add blurb
* gh-116381: Specialize CONTAINS_OP (GH-116385)Ken Jin2024-03-061-1/+2
| | | | | | | | | | | * Specialize CONTAINS_OP * 📜🤖 Added by blurb_it. * Add PyAPI_FUNC for JIT --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* chore: fix typos (#116345)cui fliter2024-03-051-1/+1
| | | Signed-off-by: cui fliter <imcusg@gmail.com>
* gh-114763: Protect lazy loading modules from attribute access races (GH-114781)Chris Markiewicz2024-02-241-30/+51
| | | 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.
* Add missed `stream` argument (#111775)Alexander Shadchin2024-02-201-1/+1
| | | | | * Add missed `stream` argument * Add news
* ``importlib/_bootstrap.py``: Reduce size of ``_List`` instances (GH-114747)Kirill Podoprigora2024-01-301-1/+1
| | | Reduce size of _List instances
* gh-109653: Improve import time of importlib.metadata / email.utils (#114664)Shantanu2024-01-291-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | My criterion for delayed imports is that they're only worth it if the majority of users of the module would benefit from it, otherwise you're just moving latency around unpredictably. mktime_tz is not used anywhere in the standard library and grep.app indicates it's not got much use in the ecosystem either. Distribution.files is not nearly as widely used as other importlib.metadata APIs, so we defer the csv import. Before: ``` λ hyperfine -w 8 './python -c "import importlib.metadata"' Benchmark 1: ./python -c "import importlib.metadata" Time (mean ± σ): 65.1 ms ± 0.5 ms [User: 55.3 ms, System: 9.8 ms] Range (min … max): 64.4 ms … 66.4 ms 44 runs ``` After: ``` λ hyperfine -w 8 './python -c "import importlib.metadata"' Benchmark 1: ./python -c "import importlib.metadata" Time (mean ± σ): 62.0 ms ± 0.3 ms [User: 52.5 ms, System: 9.6 ms] Range (min … max): 61.3 ms … 62.8 ms 46 runs ``` for about a 3ms saving with warm disk cache, maybe 7-11ms with cold disk cache.
* GH-112354: `END_FOR` instruction to only pop one value. (GH-114247)Mark Shannon2024-01-241-1/+2
| | | | * Compiler emits END_FOR; POP_TOP instead of END_FOR. To support tier 2 side exits in loops.
* gh-114265: move line number propagation before cfg optimization, remove ↵Irit Katriel2024-01-191-1/+2
| | | | guarantee_lineno_for_exits (#114267)
* gh-113238: add Anchor to importlib.resources (#113801)Mike Zimin2024-01-161-0/+2
| | | | Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-107901: synthetic jumps which are not at end of loop no longer check the ↵Irit Katriel2024-01-061-1/+2
| | | | eval breaker (#113721)
* gh-113174: Sync with importlib_metadata 7.0 (#113175)Jason R. Coombs2023-12-214-78/+130
| | | | | | | | | | | | | | | | | | | | | | | * 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-112983: Add the known magic value of 3495 for Python 3.11 bytecode (#112985)wim glenn2023-12-121-0/+1
| | | Add the known magic value of 3495 for Python 3.11 bytecode
* gh-112414: Fix `AttributeError` when calling `repr()` on a namespace package ↵Alex Waygood2023-11-271-2/+8
| | | | imported with a custom loader (#112425)
* gh-111354: Simplify _PyGen_yf by moving some of its work to the compiler and ↵Irit Katriel2023-11-031-1/+2
| | | | frame state (#111648)
* gh-111354: simplify detection of RESUME after YIELD_VALUE at except-depth 1 ↵Irit Katriel2023-11-021-1/+2
| | | | (#111459)
* Fix a misspelling of Interpeter -> Interpreter (GH-111040)Nikita Sobolev2023-10-181-1/+1
|
* GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300)Brandt Bucher2023-09-131-1/+2
|
* gh-109256: allocate opcode IDs for internal opcodes in their own range (#109269)Irit Katriel2023-09-121-1/+2
|
* gh-109039: Branch prediction for Tier 2 interpreter (#109038)Guido van Rossum2023-09-111-1/+2
| | | | | | | | | | | This adds a 16-bit inline cache entry to the conditional branch instructions POP_JUMP_IF_{FALSE,TRUE,NONE,NOT_NONE} and their instrumented variants, which is used to keep track of the branch direction. Each time we encounter these instructions we shift the cache entry left by one and set the bottom bit to whether we jumped. Then when it's time to translate such a branch to Tier 2 uops, we use the bit count from the cache entry to decided whether to continue translating the "didn't jump" branch or the "jumped" branch. The counter is initialized to a pattern of alternating ones and zeros to avoid bias. The .pyc file magic number is updated. There's a new test, some fixes for existing tests, and a few miscellaneous cleanups.
* GH-108614: Increase importlib MAGIC for RESUME_CHECK instruction (#109247)Victor Stinner2023-09-111-1/+2
|
* GH-106176, GH-104702: Fix reference leak when importing across multiple ↵Brett Cannon2023-08-291-12/+103
| | | | threads (#108497)
* gh-105481: generate op IDs from bytecode.c instead of hard coding them in ↵Irit Katriel2023-08-161-1/+2
| | | | opcode.py (#107971)
* GH-105848: Simplify the arrangement of CALL's stack (GH-107788)Brandt Bucher2023-08-091-1/+2
|
* gh-106531: Remove importlib.resources._legacy (#106532)Jason R. Coombs2023-07-142-139/+0
| | | | | | | * gh-106531: Remove importlib.resources._legacy Syncs with importlib_resources 6.0. * Remove documentation for removed functionality.
* GH-106008: Make implicit boolean conversions explicit (GH-106003)Brandt Bucher2023-06-291-1/+2
|
* gh-105775: Convert LOAD_CLOSURE to a pseudo-op (#106059)hms2023-06-291-1/+2
| | | | | | This enables super-instruction formation, removal of checks for uninitialized variables, and frees up an instruction.