summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/_bootstrap_external.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-141081: Revert "Add a `.gitignore` file to `__pycache__` folders ↵Hugo van Kemenade2025-12-151-13/+0
| | | | (#141162)" (#142758)
* gh-141081: Add a `.gitignore` file to `__pycache__` folders (#141162)Stan Ulbrych2025-12-151-0/+13
| | | | | Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Brett Cannon <brett@python.org>
* GH-65961: Stop setting `__cached__` on modules (GH-142165)Brett Cannon2025-12-111-1/+0
|
* GH-142203: Remove the `debug_override` parameter from ↵Brett Cannon2025-12-111-12/+1
| | | | `packaging.util.cache_from_source()` (GH-142204)
* GH-97850: Remove all uses and definitions of `load_module()` from importlib ↵Brett Cannon2025-12-101-29/+0
| | | | (#142205)
* gh-141930: Use the regular IO stack to write .pyc files for a better error ↵Stefano Rivera2025-11-271-6/+2
| | | | | | | | | message on failure (GH-141931) * Use open() to write the bytecode * Convert to unittest style asserts * Tweak news, thanks @vstinner * Tidy * reword NEWS, avoid word "retried"
* GH-90344: replace single-call `io.IncrementalNewlineDecoder` usage with ↵Guo Ci2025-11-151-2/+1
| | | | | | non-incremental newline decoders (GH-30276) Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Brett Cannon <brett@python.org>
* gh-135801: Add the module parameter to compile() etc (GH-139652)Serhiy Storchaka2025-11-131-4/+5
| | | | | | | Many functions related to compiling or parsing Python code, such as compile(), ast.parse(), symtable.symtable(), and importlib.abc.InspectLoader.source_to_code() now allow to pass the module name used when filtering syntax warnings.
* GH-119668: expose importlib.machinery.NamespacePath (#119669)Filipe Laíns2025-11-011-11/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * GH-119668: expose importlib.NamespacePath Signed-off-by: Filipe Laíns <lains@riseup.net> * add news Signed-off-by: Filipe Laíns <lains@riseup.net> * add to docs Signed-off-by: Filipe Laíns <lains@riseup.net> * Apply suggestions from code review Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * Fix news (importlib.NamespacePath > importlib.machinery.NamespacePath) Signed-off-by: Filipe Laíns <lains@riseup.net> * Link to module.__path__ in NamespacePath docs Signed-off-by: Filipe Laíns <lains@riseup.net> * Mention the path argument in the documentation Signed-off-by: Filipe Laíns <lains@riseup.net> * Simplify docs text Signed-off-by: Filipe Laíns <lains@riseup.net> * Highlight argument names in docs text Signed-off-by: Filipe Laíns <lains@riseup.net> * Update Lib/importlib/_bootstrap_external.py Co-authored-by: Brett Cannon <brett@python.org> * Rewrite NamespacePath's doc Signed-off-by: Filipe Laíns <lains@riseup.net> * Specify path_finder's type in the NamespacePath docstring Signed-off-by: Filipe Laíns <lains@riseup.net> * Fix doc tests Signed-off-by: Filipe Laíns <lains@riseup.net> * Apply suggestions from code review Co-authored-by: Barry Warsaw <barry@python.org> * Fix doc lint Signed-off-by: Filipe Laíns <lains@riseup.net> * Update Doc/library/importlib.rst Co-authored-by: Brett Cannon <brett@python.org> --------- Signed-off-by: Filipe Laíns <lains@riseup.net> Co-authored-by: Brett Cannon <brett@python.org> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Barry Warsaw <barry@python.org>
* gh-140633: AppleFrameworkLoader: Ignore AttributeError when setting __file__ ↵Petr Viktorin2025-10-271-1/+7
| | | | (GH-140635)
* gh-93334: Fix homonym edge case in PathFinder.find_spec() (GH-98100)Jacob Walls2025-09-051-1/+9
|
* bpo-38735: Don't fail when importing from / with sys.pycache_prefix set ↵Petr Viktorin2025-08-181-1/+2
| | | | | (GH-30456) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-115911: Ignore PermissionError during import from cwd (#116131)Alex Willmer2025-01-261-1/+1
| | | | | | | | | | | | | | | | Ignore PermissionError when checking cwd during import On macOS `getcwd(3)` can return EACCES if a path component isn't readable, resulting in PermissionError. `PathFinder.find_spec()` now catches these and ignores them - the same treatment as a missing/deleted cwd. Introduces `test.support.os_helper.save_mode(path, ...)`, a context manager that restores the mode of a path on exit. This is allows finer control of exception handling and robust environment restoration across platforms in `FinderTests.test_permission_error_cwd()`. Co-authored-by: Jason R. Coombs <jaraco@jaraco.com> Co-authored-by: Brett Cannon <brett@python.org>
* gh-121604: Make sure all deprecated items in importlib raise ↵Tomas R.2025-01-151-0/+6
| | | | | | | DeprecationWarning (#128007) Co-authored-by: rashansmith <smith.rashan@gmail.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Brett Cannon <brett@python.org>
* 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-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-122188: Move magic number to its own file (#122243)Michael Droettboom2024-07-301-276/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-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-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.
* 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-114099 - Add iOS framework loading machinery. (GH-116454)Russell Keith-Magee2024-03-191-3/+50
| | | | 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-141-0/+3
| | | | | | | | | 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>
* 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-107901: synthetic jumps which are not at end of loop no longer check the ↵Irit Katriel2024-01-061-1/+2
| | | | eval breaker (#113721)
* 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-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)
* 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-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-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.
* gh-105481: generate _specializations and _specialized_instructions from ↵Irit Katriel2023-06-191-1/+2
| | | | bytecodes.c (#105913)
* GH-77273: Better bytecodes for f-strings (GH-6132)Mark Shannon2023-06-141-2/+4
|
* Fix magic number (GH-105722)Mark Shannon2023-06-131-3/+2
|
* GH-105678: Split MAKE_FUNCTION into MAKE_FUNCTION and SET_FUNCTION_ATTRIBUTE ↵Mark Shannon2023-06-131-1/+3
| | | | (GH-105680)
* GH-105229: Replace some superinstructions with single instruction ↵Mark Shannon2023-06-051-1/+2
| | | | equivalent. (GH-105230)
* GH-104584: Plugin optimizer API (GH-105100)Mark Shannon2023-06-021-2/+3
|
* 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>