For example, the free-threaded build now generates
`lib/pkgconfig/python-3.13t.pc` and the debug build generates
`lib/pkgconfig/python-3.13d.pc`.
(cherry picked from commit 1c04c63ced)
Co-authored-by: Sam Gross <colesbury@gmail.com>
This is the only static type in the module that we will not keep static.
(cherry picked from commit 548a11d5cf)
(cherry-picked from commit 34f9b3e724)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Co-authored by: Kirill Podoprigora <kirill.bast9@mail.ru>
gh-117142: Slightly hacky fix for memory leak of StgInfo (GH-119424)
Add a funciton that inlines PyObject_GetTypeData and skips
type-checking, so it doesn't need access to the CType_Type object.
This will break if the memory layout changes, but should
be an acceptable solution to enable ctypes in subinterpreters in
Python 3.13.
Mark _ctypes as safe for multiple interpreters
(cherry picked from commit a192547dfe)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
gh-118055: Update the finder glossary entry (GH-118278)
(cherry picked from commit db009348b4)
Co-authored-by: Lincoln <71312724+Lincoln-developer@users.noreply.github.com>
subprocess docs: Fix semantically important typo (GH-119752)
GH-25416 accidentally replaced a reference to the *stderr* argument of
`subprocess.run` with a reference to the *stdin* argument. *stdin* is
not affected by the `check_output` option.
(cherry picked from commit 2cc3502f98)
Co-authored-by: Zachary Ware <zach@python.org>
GH-89727: Fix FD leak on `os.fwalk()` generator finalization. (GH-119766)
Follow-up to 3c890b50. Ensure we `os.close()` open file descriptors when
the `os.fwalk()` generator is finalized.
(cherry picked from commit a5fef800d3)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
GH-89727: Fix `os.fwalk()` recursion error on deep trees (GH-119638)
Implement `os.fwalk()` using a list as a stack to avoid emitting recursion
errors on deeply nested trees.
(cherry picked from commit 3c890b503c)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
gh-119260: Clarify is_dataclass Behavior for Subclasses in Documentation and Tests (GH-119480)
(cherry picked from commit bf4ff3ad2e)
Co-authored-by: Aditya Borikar <adityaborikar2@gmail.com>
Co-authored-by: Carl Meyer <carl@oddbird.net>
This is an unrevert of d58ebf0 (gh-119636), which was reverted by 9216a53 (gh-119639) due to problems which have been resolved.
This is minimal support for multiphase init. Subinterpreters are not supported yet. That will be addressed in a later change.
(cherry picked from commit 3e8b609)
Co-authored-by: Erlend E. Aasland erlend@python.org
GH-119169: Implement `pathlib.Path.walk()` using `os.walk()` (GH-119573)
For silly reasons, pathlib's generic implementation of `walk()` currently
resides in `glob._Globber`. This commit moves it into
`pathlib._abc.PathBase.walk()` where it really belongs, and makes
`pathlib.Path.walk()` call `os.walk()`.
(cherry picked from commit 7ff61f51b6)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
GH-89727: Partially fix `shutil.rmtree()` recursion error on deep trees (GH-119634)
Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.
`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.
(cherry picked from commit a150679f90)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
The deadlock only affected the free-threaded build and only occurred
when the GIL was enabled at runtime. The `Py_DECREF(old_name)` call
might temporarily release the GIL while holding the type seqlock.
Another thread may spin trying to acquire the seqlock while holding the
GIL.
The deadlock occurred roughly 1 in ~1,000 runs of `pool_in_threads.py`
from `test_multiprocessing_pool_circular_import`.
(cherry picked from commit c22323cd1c)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712)
When the _Py_SINGLETON() is used, Argument Clinic now adds an
explicit "pycore_runtime.h" include to get the macro. Previously, the
macro may or may not be included indirectly by another include.
(cherry picked from commit 7ca74a760a)
gh-119443: Turn off from __future__ import annotations in REPL (GH-119493)
(cherry picked from commit a8e35e8eba)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
xmltok_impl.c and xmltok_ns.c are _included_ in xmltok.c by the C
pre-processor.
(cherry picked from commit 606be66362)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
This is a backport of 3 commits that go together.
(cherry picked from commit a895756)
(cherry picked from commit b30d30c)
(cherry picked from commit a89fc26)
- Cache line object to avoid creating a Unicode object
for all of the tokens in the same line.
- Speed up byte offset to column offset conversion by using the
smallest buffer possible to measure the difference.
(cherry picked from commit d87b015106)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
gh-119581: Add a test of InitVar with name shadowing (GH-119582)
(cherry picked from commit 6ec371223d)
Co-authored-by: Steven Troxler <steven.troxler@gmail.com>
gh-119317: findall instead of traverse for docutils nodes (GH-119319)
(cherry picked from commit 0867bce457)
Co-authored-by: Carlos Meza <hire@carlosmeza.com>
This is minimal support. Subinterpreters are not supported yet. That will be addressed in a later change.
(cherry picked from commit 3e8b60905e)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
The fix in gh-119561 introduced an assertion that doesn't hold true if any of the three new test extension modules are loaded more than once. This is fine normally but breaks if the new test_check_state_first() is run more than once, which happens for refleak checking and with the regrtest --forever flag. We fix that here by clearing each of the three modules after loading them. We also tweak a check in _modules_by_index_check().
(cherry picked from commit ae7b17673f)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
The assertion was added in gh-118532 but was based on the invalid assumption that PyState_FindModule() would only be called with an already-initialized module def. I've added a test to make sure we don't make that assumption again.
(cherry picked from commit 0c5ebe13e9)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
gh-111997: Fix argument count for LINE event and clarify type of argument counts. (GH-119179)
(cherry picked from commit 70b07aa415)
Co-authored-by: scoder <stefan_ml@behnel.de>
`Out-File -Encoding utf8` and similar commands in Windows Powershell 5.1 emit
UTF-8 with a BOM marker, which the regular `utf-8` codec decodes incorrectly.
`utf-8-sig` accepts a BOM, but also works correctly without one.
This change also makes .pth files match the way Python source files are handled.
(cherry picked from commit bf5b6467f8)
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
gh-69214: Fix fcntl.ioctl() request type (GH-119498)
Use an 'unsigned long' instead of an 'unsigned int' for the request
parameter of fcntl.ioctl() to support requests larger than UINT_MAX.
(cherry picked from commit 92fab3356f)
Co-authored-by: Victor Stinner <vstinner@python.org>