summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
Commit message (Collapse)AuthorAgeFilesLines
* GH-126606: don't write incomplete pyc files (GH-126627)CF Bolz-Tereick2024-11-131-1/+5
| | | | Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru> Co-authored-by: Brett Cannon <brett@python.org>
* gh-125519: Improve traceback if `importlib.reload()` is called with a ↵Alex Waygood2024-10-211-1/+1
| | | | non-module object (#125520)
* gh-123085: Fix issue in inferred caller when resources package has no source ↵Jason R. Coombs2024-09-121-2/+3
| | | | | | | (#123102) gh-123085: Fix issue in inferred caller when resources package has no source. From importlib_resources 6.4.3 (python/importlib_resources#314).
* gh-121735: Fix module-adjacent references in zip files (#123037)Jason R. Coombs2024-09-121-2/+4
| | | | | | | | | | | | | | | * 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.
* Fix typos in warnings, docstrings, comments and text files (#123597)abstractee2024-09-031-1/+1
|
* gh-116608: Apply style and compatibility changes from importlib_metadata. ↵Jason R. Coombs2024-08-151-5/+1
| | | | (#123028)
* gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952)Eric Snow2024-08-131-8/+8
| | | 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.
* gh-122188: Remove _imp.pyc_magic_number (GH-122503)Serhiy Storchaka2024-08-021-1/+1
| | | _imp.pyc_magic_number_token should be enough.
* gh-122555: Remove removed functions from `Doc/data/refcounts.dat` (#122556)Bénédikt Tran2024-08-011-1/+0
|
* gh-122188: Move magic number to its own file (#122243)Michael Droettboom2024-07-302-278/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gh-122188: Move magic number to its own file * Add versionadded directive * Do work in C * Integrate launcher.c * Make _pyc_magic_number private * Remove metadata * Move sys.implementation -> _imp * Modernize comment * Move _RAW_MAGIC_NUMBER to the C side as well * _pyc_magic_number -> pyc_magic_number * Remove unused import * Update docs * Apply suggestions from code review Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com> * Fix typo in tests --------- Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* GH-122160: Remove BUILD_CONST_KEY_MAP opcode. (GH-122164)Mark Shannon2024-07-251-1/+2
|
* gh-117983: Defer import of threading for lazy module loading (#120233)Chris Markiewicz2024-07-031-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* gh-120910: Fix issue resolving relative paths outside site-packages. (#120911)Jason R. Coombs2024-06-231-1/+1
| | | Incorporates changes from importlib_metadata 7.2.1.
* GH-120507: Lower the `BEFORE_WITH` and `BEFORE_ASYNC_WITH` instructions. ↵Mark Shannon2024-06-181-2/+3
| | | | | | | | | (#120640) * Remove BEFORE_WITH and BEFORE_ASYNC_WITH instructions. * Add LOAD_SPECIAL instruction * Reimplement `with` and `async with` statements using LOAD_SPECIAL
* gh-120417: Fix "imported but unused" linter warnings (#120461)Victor Stinner2024-06-142-0/+14
| | | | | | | | | | | Add __all__ to the following modules: importlib.machinery, importlib.util and xml.sax. Add also "# noqa: F401" in collections.abc, subprocess and xml.sax. * Sort __all__; remove collections.abc.__all__; remove private names * Add tests
* gh-120417: Remove unused imports in the stdlib (#120420)Victor Stinner2024-06-121-1/+0
|
* gh-106531: Apply changes from importlib_resources 6.3.2 (#117054)Jason R. Coombs2024-06-042-2/+54
| | | Apply changes from importlib_resources 6.3.2.
* gh-93963: Remove deprecated names from importlib.abc (#119720)Hugo van Kemenade2024-05-291-15/+0
| | | | Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* gh-119311: Fix name mangling with PEP 695 generic classes (#119464)Jelle Zijlstra2024-05-281-1/+2
| | | | Fixes #119311. Fixes #119395.
* gh-119180: Update the magic number (#119397)Jelle Zijlstra2024-05-251-1/+1
| | | | PR #119321 added a comment about the magic number bump but did not actually apply the new magic number.
* gh-119180: Add LOAD_COMMON_CONSTANT opcode (#119321)Jelle Zijlstra2024-05-221-2/+3
| | | | | | | | | | The PEP 649 implementation will require a way to load NotImplementedError from the bytecode. @markshannon suggested implementing this by converting LOAD_ASSERTION_ERROR into a more general mechanism for loading constants. This PR adds this new opcode. I will work on the rest of the implementation of the PEP separately. Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* 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
|