(cherry picked from commit e9d845b41d)
Includes fix for off-by-one error from GH-134867
(cherry-picked from commit e64395e8eb)
Co-authored-by: Emma Smith <emma@emmatyping.dev>
GH-134848: Use a set to store ``AuditEvents.sources`` (GH-134849)
(cherry picked from commit b265a7ddeb)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
gh-132983: Convert dict_content to take Py_buffer in ``ZstdDict()`` (GH-133924)
(cherry picked from commit f2ce4bbdfd)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
gh-133711: Fix test_readline.test_nonascii() for UTF-8 Mode (GH-134841)
Skip the test if the Python UTF-8 Mode is enabled and the LC_CTYPE
encoding is not UTF-8.
(cherry picked from commit 4635115c3f)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-133711: Fix test_regrtest for PYTHONUTF8=1 (GH-134839)
Use "backslashreplace" error handler to decode stdout and stderr.
Example:
vstinner@WIN C:\victor\python\main\build\test_python_worker_8360\x91>
"C:\victor\python\main\PCbuild\amd64\python_d.exe" -m test
--fast-ci --slow-ci --testdir
C:\Users\vstinner\AppData\Local\Temp\tmp0t59e8da
test_regrtest_noop1 test_regrtest_noop2 test_regrtest_noop3
test_regrtest_noop4
Notice the "\x91" byte at the end of the first line: it's the
non-ASCII U+00E6 character encoded to the OEM cp437 code page.
(cherry picked from commit 91618278e7)
Co-authored-by: Victor Stinner <vstinner@python.org>
Update outdated statement from `math` about C standard (GH-134621)
(cherry picked from commit 21672b694b)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Fix typing.TYPE_CHECKING docs to reflect PEP 649. (GH-134813)
typing.TYPE_CHECKING should no longer steer users towards
manual or automatic stringization (and PEP 563); PEP 649
makes all that unnecessary.
(cherry picked from commit d7256ae4d7)
Co-authored-by: larryhastings <larry@hastings.org>
This is the same underlying bug as gh-130519. The destructor may call
arbitrary code, changing the `tstate->qsbr pointer` and invalidating the
old `struct _qsbr_thread_state`.
(cherry picked from commit a4d37f88b6)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-134789: Document del s[i] operation for mutable sequences (GH-134804)
[main] Update stdtypes.rst
- Added explicit mention of `del s[i]` (item deletion by index) to the Mutable Sequence Types section.
- Clarified that this operation removes the item at the specified index from the sequence.
- Addresses issue GH-134789.
(cherry picked from commit 967f361993)
Co-authored-by: Rishabh Singh <67859818+rishabh11336@users.noreply.github.com>
gh-132917: fix data race on `last_mem` in free-threading gc (GH-134692)
(cherry picked from commit ac539e7e0d)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This is a small follow-up to gh-133481. There's a corner case
in the behavior of PyImport_ImportModuleAttrString(), where
it expects __builtins__ to be set if __globals__ is set.
(cherry picked from commit 9b5e80000, AKA gh-134758)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
gh-133678: Document C API third party tools (GH-134526)
(cherry picked from commit c3c88064f5)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Steve Dower <steve.dower@python.org>
gh-62824: Adjust test_alias_modules_exist test to use imports instead of file checks (GH-134777)
(cherry picked from commit 8704d6b391)
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
gh-134752: Improve speed of test_tokenize.StringPrefixTest.test_prefixes. (GH-134766)
(cherry picked from commit 579686d9fb)
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
gh-134160: Use multi-phase init in documentation examples (GH-134296)
(cherry picked from commit 96905bdd27)
Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
gh-134675: Add t-string prefixes to tokenizer module, lexical analysis doc, and add a test to make sure we catch this error in the future. (GH-134734)
* Add t-string prefixes to _all_string_prefixes, and add a test to make sure we catch this error in the future.
* Update lexical analysis docs for t-string prefixes.
(cherry picked from commit 08c78e02fa)
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
Disable immortalization around Py_CompileString*().
The same approach as 332356b that fixed the refleaks in compile() and eval().
E: 09e72cf can pass test_capi, test_sys and test__interpchannels with this patch for me.
(cherry picked from commit c60f39ada6, AKA gh-134686)
Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
gh-134637: Fix performance regression in calling `ctypes` function pointer in `free threading`. (GH-134702)
Fix performance regression in calling `ctypes` function pointer in `free threading`.
(cherry picked from commit 3c0525126e)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
gh-119180: Updates to PEP 649/749 docs (GH-134640)
- Mention (again) that `type.__annotations__` is unsafe. It is now safe
when using only classes defined under PEP 649 semantics, but not with
classes defined using `from __future__ import annotations`.
- Mention that annotations on instances no longer work. There was already
an issue about this.
- Mention the general changes in the "Porting to Python 3.14" section.
- `annotationlib` was proposed by PEP-749, not PEP-649.
(cherry picked from commit 7291eaba8b)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Emma Smith <emma@emmatyping.dev>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
gh-132493: Remove __annotations__ usage in inspect._signature_is_functionlike (GH-133415)
This check is potentially problematic because it could force evaluation of
annotations unnecessarily. This doesn't trigger for builtin objects (functions,
classes, or modules) with annotations, but it could trigger for third-party objects.
The check was not particularly useful anyway, because it succeeds if ``__annotations__``
is a dict or None, so the only thing this did was guard against objects that have an
``__annotations__`` attribute that is of some other type. That doesn't seem particularly
useful, so I just removed the check.
(cherry picked from commit cb6596c6aa)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
gh-132876: workaround broken ldexp() on Windows 10 (GH-133135)
* gh-132876: workaround broken ldexp() on Windows 10
ldexp() fails to round subnormal results before Windows 11,
so hide their bug.
(cherry picked from commit cf8941c603)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Tim Peters <tim.peters@gmail.com>
gh-91048: Refactor and optimize remote debugging module (#134652)
Completely refactor Modules/_remote_debugging_module.c with improved
code organization, replacing scattered reference counting and error
handling with centralized goto error paths. This cleanup improves
maintainability and reduces code duplication throughout the module while
preserving the same external API.
Implement memory page caching optimization in Python/remote_debug.h to
avoid repeated reads of the same memory regions during debugging
operations. The cache stores previously read memory pages and reuses
them for subsequent reads, significantly reducing system calls and
improving performance.
Add code object caching mechanism with a new code_object_generation
field in the interpreter state that tracks when code object caches need
invalidation. This allows efficient reuse of parsed code object metadata
and eliminates redundant processing of the same code objects across
debugging sessions.
Optimize memory operations by replacing multiple individual structure
copies with single bulk reads for the same data structures. This reduces
the number of memory operations and system calls required to gather
debugging information from the target process.
Update Makefile.pre.in to include Python/remote_debug.h in the headers
list, ensuring that changes to the remote debugging header force proper
recompilation of dependent modules and maintain build consistency across
the codebase.
Also, make the module compatible with the free threading build as an extra :)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 42b25ad4d3)
gh-115999: Add PyCodeObject.co_tlbc to the debug offsets (GH-134286)
(cherry picked from commit dd7f113057)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>