Commit Graph
10478 Commits
Author SHA1 Message Date
Timofei IvankovandGitHub 398dbef62a [3.15] gh-154902: Type-check the SET_ADD operand (#155071) 2026-08-04 13:03:28 +03:00
Mark ShannonandGitHub e972f76ac1 [3.15] Backport GH-148874: Make sure that mngr.__exit__() is always called in a with statement (GH-150911) (GH-154830)
* Even if there is an interrupt during the call to mngr.__enter__()
2026-08-03 16:23:34 +01:00
23b2b40d55 [3.15] gh-122931: Allow stable abi3 API extensions to include a multiarch tuple in the filename (GH-152461) (GH-154772)
This permits stable ABI extensions for multiple architectures to be
co-installed into the same directory, without clashing with each other,
the same way (non-stable ABI) regular extensions can.

It is listed before the current platform-less suffixes since it's more
specific.

The platform is stored in a new pyconfig.h define & sysconfig
variable, SOABI_PLATFORM.
On some known architectures (FreeBSD, Windows), this
will be undefined/zero; these won't have the new tag (yet).

Add SOABI_PLATFORM & ALT_SOABI the info to
`make pythoninfo` as well.
(cherry picked from commit 7961bbf2bb)

Co-authored-by: Stefano Rivera <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
2026-07-29 10:21:30 +02:00
de106cc321 [3.15] gh-154822: Fix racy assertion during finalization (GH-154824) (GH-154828)
(cherry picked from commit cb0f028537)

Co-authored-by: Peter Bierma <[email protected]>
2026-07-28 16:39:33 +00:00
44fca7ed29 [3.15] gh-154431: Revert "gh-154431: Fix data race in sys.audithook (GH-154462)" (GH-154769) (GH-154774)
This reverts commit 596cd5c5d7.
This commit caused a refleak.

(cherry picked from commit c7b9a13a75)

Co-authored-by: Petr Viktorin <[email protected]>
2026-07-27 18:02:16 +02:00
4245891a87 [3.15] gh-134745: Remove dead code in thread_nt.h left by gh-134747 (GH-154338) (#154655)
gh-134745: Remove dead code in `thread_nt.h` left by gh-134747 (GH-154338)
(cherry picked from commit 9560bd8f35)

Co-authored-by: Ivy Xu <[email protected]>
2026-07-24 23:01:47 +00:00
e9d9fd9c80 [3.15] gh-154431: Fix data race in sys.audithook (GH-154462) (#154477)
gh-154431: Fix data race in `sys.audithook` (GH-154462)
(cherry picked from commit 596cd5c5d7)

Co-authored-by: sobolevn <[email protected]>
2026-07-22 12:41:16 +00:00
e8206b6ca5 [3.15] gh-154014: Initialize cold executor vm_data fields (GH-154142) (GH-154457)
gh-154014: Initialize cold executor vm_data fields (GH-154142)
(cherry picked from commit d1174a48ea)

Co-authored-by: Bhuvansh <[email protected]>
2026-07-22 09:49:29 +00:00
387f7cd81d [3.15] gh-154283: Make threading.get_native_id() unique across processes on DragonFly (GH-154287) (GH-154293)
On DragonFly BSD lwp_gettid() is only unique within a process (the main
thread is always LWP 1), so combine it with the process id, like Solaris.
(cherry picked from commit 53597df11e)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
2026-07-20 20:20:57 +00:00
0cb0723178 [3.15] gh-153236: Propagate lazy submodule import errors (GH-153237) (#153936)
gh-153236: Propagate lazy submodule import errors (GH-153237)
(cherry picked from commit 0a09dafb03)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
2026-07-18 16:04:40 +00:00
9fcebd38b5 [3.15] gh-151644: Fix data race in sys.setdlopenflags/getdlopenflags under free-threading (gh-151768) (#153790)
gh-151644: Fix data race in sys.setdlopenflags/getdlopenflags under free-threading (gh-151768)

In free-threading builds, concurrent calls to sys.getdlopenflags() and
sys.setdlopenflags() race on interp->imports.dlopenflags.  Fix by
using FT_ATOMIC_LOAD_INT_RELAXED / FT_ATOMIC_STORE_INT_RELAXED in
_PyImport_GetDLOpenFlags and _PyImport_SetDLOpenFlags, consistent with
how analogous interpreter-state integer fields (lazy_imports_mode,
pystats_enabled) are protected.

Relaxed ordering is correct here: dlopenflags is a standalone config
integer with no ordering relationship to other memory.
(cherry picked from commit cde31ec135)

Co-authored-by: Jiucheng(Oliver) <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
2026-07-16 15:53:07 +05:30
35975878e6 [3.15] gh-141510: Update marshal module comment with frozendict support (GH-153655) (#153681)
gh-141510: Update `marshal` module comment with `frozendict` support (GH-153655)
(cherry picked from commit 37571ea82a)

Co-authored-by: sobolevn <[email protected]>
2026-07-14 07:24:56 +00:00
462f62819b [3.15] gh-152132: Test Py_CompileString() in test_capi.test_run (GH-153470) (#153472)
gh-152132: Test Py_CompileString() in test_capi.test_run (GH-153470)

PyRun functions now raises ValueError if the start argument is
invalid.

* Add Modules/_testlimitedcapi/run.c.
* Rename _Py_CompileStringObjectWithModule() to
  _Py_CompileStringObject().
(cherry picked from commit d83d26724b)

Co-authored-by: Victor Stinner <[email protected]>
2026-07-10 02:07:38 +00:00
76c28fc107 [3.15] gh-152132: Fix Py_RunMain() to return an exit code (GH-153446) (#153454)
gh-152132: Fix Py_RunMain() to return an exit code (GH-153446)

* Fix Py_RunMain() to return an exit code, rather than calling
  Py_Exit(), when running a script, a command, or the REPL.
* _PyRun_SimpleFile() now logs errors to stderr, for example if setting
  __main__.__file__ fails.
* Add tests on Py_RunMain() exitcode.
* Rename functions:

  * _PyRun_SimpleStringFlagsWithName() => _PyRun_SimpleString()
  * _PyRun_SimpleFileObject() => _PyRun_SimpleFile()
  * _PyRun_AnyFileObject() => _PyRun_AnyFile()
  * _PyRun_InteractiveLoopObject() => _PyRun_InteractiveLoop()

* Change _PyRun_SimpleString(), _PyRun_SimpleFile(), _PyRun_AnyFile() and
  _PyRun_InteractiveLoop() return type to PyObject*.
* pymain_repl() now displays the error if PySys_Audit() or
  import _pyrepl failed.
* PyRun_SimpleFileExFlags() and PyRun_AnyFileExFlags() now log
  PyUnicode_DecodeFSDefault() error. So these functions can no longer
  return -1 with an exception set.
(cherry picked from commit fac72f1ee9)

Co-authored-by: Victor Stinner <[email protected]>
2026-07-09 19:00:28 +00:00
64048038a6 [3.15] gh-152132: Test all PyRun functions in test_capi.test_run (GH-153352) (#153411)
gh-152132: Test all PyRun functions in test_capi.test_run (GH-153352)

PyRun_InteractiveOneObjectEx() now raises TypeError if the second
parameter type is not str.
(cherry picked from commit cd9994e283)

Co-authored-by: Victor Stinner <[email protected]>
2026-07-09 11:21:50 +00:00
c5e73f8c91 [3.15] gh-153300: Set global configuration variables in PyConfig_Set() (GH-153301) (#153356)
gh-153300: Set global configuration variables in PyConfig_Set() (GH-153301)

PyConfig_Set() now also set global configuration variables. For
example, PyConfig_Set("inspect", value) now also sets Py_InspectFlag.

Use PyConfig_Set() in main.c to set the inspect flag. Python code can
now see the updated sys.flags.inspect value.
(cherry picked from commit 9fb713f1b8)

Co-authored-by: Victor Stinner <[email protected]>
2026-07-08 20:21:20 +02:00
c30c8a4a65 [3.15] gh-153252: Fix error handling in _PyCompile_CodeGen (GH-153253) (#153281)
gh-153252: Fix error handling in `_PyCompile_CodeGen` (GH-153253)
(cherry picked from commit a74280e669)

Co-authored-by: sobolevn <[email protected]>
2026-07-07 20:27:32 +03:00
Miss Islington (bot)GitHubAn Longblurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>sobolevn
7342e01253 [3.15] gh-153205: Set MemoryError in stackref array conversion (GH-153206) (#153272)
gh-153205: Set `MemoryError` in stackref array conversion (GH-153206)
(cherry picked from commit 08759ff101)

Co-authored-by: An Long <[email protected]>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: sobolevn <[email protected]>
2026-07-07 16:34:17 +00:00
ffb5184dfb [3.15] gh-152682: Fix NULL dereference on OOM in symtable_visit_type_param_bound_or_default (GH-152684) (#152695)
In `symtable_visit_type_param_bound_or_default()`, when a reserved name
(e.g. `__classdict__`) is used as a type parameter, `PyUnicode_FromFormat()`
is called to build the SyntaxError message. If the allocation fails and
returns NULL, the subsequent `PyErr_SetObject()` and `Py_DECREF()` calls
would dereference NULL, causing a segfault.

Fix by returning 0 immediately when `PyUnicode_FromFormat()` returns NULL.
This propagates the MemoryError set by `PyUnicode_FromFormat()`.

The bug was introduced in gh-128632 (commit 891c61c).
(cherry picked from commit 10ed03edf1)

Co-authored-by: Petr Vaganov <[email protected]>

* Remove test

---------

Co-authored-by: Petr Vaganov <[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>
2026-07-06 17:36:32 +01:00
15a21e4ee2 [3.15] gh-152849: Fix OverflowError message for out-of-range timestamps in the time module (GH-152850) (#153209)
(cherry picked from commit 2d7a74ece7)

Co-authored-by: tonghuaroot (童话) <[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>
2026-07-06 15:25:47 +00:00
fe23abac94 [3.15] gh-152903: Change PCWSTR to PWSTR in GetThreadDescription() typedef (GH-152904) (#152943)
gh-152903: Change PCWSTR to PWSTR in GetThreadDescription() typedef (GH-152904)

Fixes issue GH-152903
(cherry picked from commit ac1acb6d7d)

Co-authored-by: Carlo Bramini <[email protected]>
2026-07-03 11:33:14 +00:00
Miss Islington (bot)andGitHub d13f5b27c8 [3.15] gh-151763: Fix OOM-0013 crash when the parser or compiler fails to allocate (GH-151968) (#152836) 2026-07-02 09:23:23 +01:00
0f3e91b1f8 [3.15] gh-151126: Fix a possible crash during the startup with no memory under Py_STACKREF_DEBUG (GH-152478) (#152677)
gh-151126: Fix a possible crash during the startup with no memory under `Py_STACKREF_DEBUG` (GH-152478)
(cherry picked from commit ecdef17730)

Co-authored-by: sobolevn <[email protected]>
2026-06-30 11:56:43 +00:00
00a43044d8 [3.15] gh-152375: Fix undefined behaviour in the INSTRUMENTED_JUMP macro (GH-152376) (#152566)
(cherry picked from commit cdec9acd63)

Co-authored-by: Stan Ulbrych <[email protected]>
2026-06-29 09:54:27 +00:00
2b92f57cac [3.15] GH-151672: __lazy_import__ always resolves to the module being imported (GH-151827) (#152534)
GH-151672: `__lazy_import__` always resolves to the module being imported (GH-151827)
(cherry picked from commit 2d0003c0b2)

Co-authored-by: Brandt Bucher <[email protected]>
2026-06-29 10:23:25 +01:00
65695ebffa [3.15] GH-151619: Ensure non-module global/builtin namespaces are watched for lazy imports (GH-151762) (#152533)
GH-151619: Ensure non-module global/builtin namespaces are watched for lazy imports (GH-151762)
(cherry picked from commit 7ed9062dd0)

Co-authored-by: Brandt Bucher <[email protected]>
2026-06-28 22:53:20 +00:00
Pablo Galindo SalgadoandGitHub 65fbec64f6 [3.15] gh-151613: Fix remote debugging frame cache ABA (#152448)
gh-151613: Fix remote debugging frame cache ABA (#151614)

The remote debugging frame cache previously used only the last_profiled_frame address as its cache anchor. If a frame returned and a later frame reused the same _PyInterpreterFrame address, the profiler could accept a stale cache entry and splice parent frames from a different call chain into the current stack.

This adds a last_profiled_frame_seq counter next to last_profiled_frame, increments it when the anchor advances, stores it in frame cache entries, and validates cache hits against both the frame address and the sequence. Cache miss walks now copy stack chunks before storing new cache entries so stored continuations come from a stable snapshot. The new regression test exercises alternating call chains and checks that cached stacks never contain frames from both branches.

(cherry picked from commit 8cda6ae2f1)
2026-06-27 17:42:31 +00:00
e88d41685b [3.15] gh-151029: Fix sys.remote_exec() unable to find writable memory when libpython replaced on disk (GH-151032) (#152443)
gh-151029: Fix sys.remote_exec() unable to find writable memory when libpython replaced on disk (GH-151032)
(cherry picked from commit a69d0fc41e)

Co-authored-by: Łukasz Langa <[email protected]>
Co-authored-by: Pablo Galindo <[email protected]>
2026-06-27 16:49:40 +00:00
eaf4d73112 [3.15] gh-148825: Fix build error if specialization is disabled (GH-148826) (#152206)
gh-148825: Fix build error if specialization is disabled (GH-148826)
(cherry picked from commit 56ae0b8e4f)

Co-authored-by: Marc Mueller <[email protected]>
2026-06-25 14:36:04 +00:00
415e218ed5 [3.15] gh-151842: Fix crash upon OOM in _interpreters.capture_exception (GH-151843) (GH-152031)
(cherry picked from commit 5e0747db2f)

Co-authored-by: Amrutha <[email protected]>
2026-06-23 20:58:10 +00:00
7b765a47b8 [3.15] gh-151773: Fix NULL dereference in PyContextVar_Set (GH-151836) (#152009)
gh-151773: Fix NULL dereference in `PyContextVar_Set` (GH-151836)
(cherry picked from commit d35b1719a5)

Co-authored-by: dev <[email protected]>
2026-06-23 14:46:05 +00:00
80d7626c74 [3.15] gh-150902: Optimize PyCriticalSection2 to skip locking the same locks held by the current CS2 (gh-151554)
This mimics an optimization already present for the single-mutex critical section.
(cherry picked from commit c2ca7724af)

Co-authored-by: Daniele Parmeggiani <[email protected]>
2026-06-19 09:52:07 -04:00
3135ab811d [3.15] gh-151436: Fix missing tstate->last_profiled_frame updates (GH-151437) (#151612)
gh-151436: Fix missing `tstate->last_profiled_frame` updates (GH-151437)
(cherry picked from commit a8d74c062f)

Co-authored-by: Maurycy Pawłowski-Wieroński <[email protected]>
2026-06-19 10:24:53 +02:00
8fe5897853 [3.15] gh-151510: Fix __lazy_import__ without frame (GH-151511) (#151610)
gh-151510: Fix __lazy_import__ without frame (GH-151511)
(cherry picked from commit eff805b7a7)

Co-authored-by: AN Long <[email protected]>
2026-06-17 18:40:33 +00:00
Victor StinnerandGitHub a5c5edddbc [3.15] gh-151546: Fix stack limits on musl (#151548) (#151583)
gh-151546: Fix stack limits on musl (#151548)

If the thread stack size is set by linker flags, pass the stack size
to Python/ceval.c via the new _Py_LINKER_THREAD_STACK_SIZE variable
to set Py_C_STACK_SIZE macro.

(cherry picked from commit 9a61d1c0c8)
2026-06-17 11:13:40 +02:00
ff6e973c3b [3.15] gh-151218: Replace sys.flags in PyConfig_Set() (GH-151402) (#151552)
gh-151218: Replace sys.flags in PyConfig_Set() (GH-151402)

PyConfig_Set() and sys.set_int_max_str_digits() now replace
sys.flags (create a new object), instead of modifying sys.flags in-place.

Modifying sys.flags in-place can lead to data races when multiple
threads are reading or writing sys.flags in parallel.

Use _Py_atomic functions to get and set max_str_digits members.
(cherry picked from commit b16d23fc9f)

Co-authored-by: Victor Stinner <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
2026-06-16 16:48:56 +00:00
255b3fff97 [3.15] gh-151223: fix tsan data races in load global specializations (GH-151393) (#151513)
gh-151223: fix tsan data races in load global specializations (GH-151393)
(cherry picked from commit e9d5280f6c)

Co-authored-by: Kumar Aditya <[email protected]>
2026-06-15 22:52:52 +05:30
42e81e35a0 [3.15] gh-151112: Fix crash in compiler_mod() when entering the current compilation unit fails (GH-151234) (#151350)
(cherry picked from commit 937d89c4d9)

Co-authored-by: Stan Ulbrych <[email protected]>
2026-06-11 15:22:31 +00:00
e3b94d8fa4 [3.15] gh-151112: Move an assert that may fail in cfg_builder_check (GH-151153) (#151313)
(cherry picked from commit 2d3381035d)

Co-authored-by: Stan Ulbrych <[email protected]>
2026-06-11 09:46:04 +00:00
e8d914fd49 [3.15] gh-151278: Fix test_faulthandler on UBSan (GH-151279) (#151281)
gh-151278: Fix test_faulthandler on UBSan (GH-151279)

* Py_FatalError() no longer calls _PyFaulthandler_Fini() if it
  doesn't hold the GIL.
* Skip test_faulthandler tests raising signals if run with UBSan.
* Enable test_faulthandler in GitHub Action "Reusable Sanitizer".
(cherry picked from commit e60c42dc3f)

Co-authored-by: Victor Stinner <[email protected]>
2026-06-10 20:07:07 +00:00
Victor StinnerandGitHub 10f616cf39 [3.15] gh-151253: Dump the Python path configuration on _PyCodec_InitRegistry() failure (#151250) (#151269)
gh-151253: Dump the Python path configuration on _PyCodec_InitRegistry() failure (#151250)

If "import encodings" fails at Python startup, dump the Python path
configuration to help users debugging their configuration. The
encodings module is the first module imported during Python startup.

(cherry picked from commit 7b6e98911e)
2026-06-10 22:03:27 +02:00
73e5d444ac [3.15] gh-150700: Fix class-scope inline comprehensions when nested scopes reference __class__ and friends (GH-150735) (#151211)
gh-150700: Fix class-scope inline comprehensions when nested scopes reference `__class__` and friends (GH-150735)

* Fix class-scope inline comprehensions when nested scopes reference `__class__` and friends

In `inline_comprehension()`, when `__class__` / `__classdict__` /
`__conditional_annotations__` appears as `FREE` in a comprehension's
symbol table because a nested scope captured it (e.g. nested lambdas),
this name is still discarded from `comp_free` unconditionally.

This prevents `drop_class_free()` from seeing it, so the appropriate
`ste_needs_(...)` flag is never set on the enclosing class.
That leads to `codegen_make_closure()` throwing `SystemError` when it
couldn't find `__class__` / `__classdict__` /
`__conditional_annotations__` in the class's cellvars.

From now on we just discard from `comp_free` when no child scope
(e.g. a lambda) still needs the name as `FREE`. When a child scope does
need it, keep it in `comp_free` so `drop_class_free()` can set the
appropriate flag and the class creates the implicit cell.

* Fix tests

* Fix typo

* Fix formatting

* Add test checking validity of `__class__` returned

* Prefer 'used' to 'deferred'
(cherry picked from commit ce916dc506)

Co-authored-by: Bartosz Sławecki <[email protected]>
2026-06-09 16:33:04 -07:00
50765f43f7 [3.15] gh-151112: Fix double free in assemble_init when out of memory (GH-151142) (#151205)
gh-151112: Fix double free in `assemble_init` when out of memory (GH-151142)
(cherry picked from commit 580499177c)

Co-authored-by: Stan Ulbrych <[email protected]>
2026-06-09 20:16:42 +00:00
8a2bf2a072 [3.15] gh-151126: Fix missing PyErr_NoMemory() in remove_unused_consts (GH-151127) (#151134)
gh-151126: Fix missing `PyErr_NoMemory()` in `remove_unused_consts` (GH-151127)
(cherry picked from commit 3186547c1e)

Co-authored-by: sobolevn <[email protected]>
2026-06-09 10:33:02 +00:00
Pablo Galindo SalgadoandGitHub 83e26a43a7 [3.15] gh-149321: Remove lazy_imports=none startup mode (GH-149389) (#150129) 2026-06-08 22:55:57 +00:00
5751633fac [3.15] gh-150633: Properly handle null characters in the name when importing frozen modules (GH-150634) (GH-151100)
(cherry picked from commit 54de5475cd)

Co-authored-by: Thomas Kowalski <[email protected]>
2026-06-08 18:58:11 +00:00
06ffcde725 [3.15] gh-146527: Fix memory leak in _PyGC_Fini() (GH-150969) (#150970)
gh-146527: Fix memory leak in _PyGC_Fini() (GH-150969)

Free generation_stats allocated by _PyGC_Init().

Fix Python/gc.c: Python/gc_free_threading.c was already fixed.
(cherry picked from commit 0036565e81)

Co-authored-by: Victor Stinner <[email protected]>
2026-06-05 14:11:37 +00:00
f8cea98b4e [3.15] gh-149805: Fix SystemError when compiling __classdict__ class annotation (GH-149806)
(cherry picked from commit c52d2b16dd)

Co-authored-by: Stan Ulbrych <[email protected]>
2026-06-03 09:39:22 +01:00
53e7f2400a [3.15] gh-150723: Fix perf jitdump files on macOS (GH-150728) (#150832)
gh-150723: Fix perf jitdump files on macOS (GH-150728)

The perf jitdump format defines the thread id field of the JR_CODE_LOAD
record as a 32-bit value, but on macOS it was declared as a uint64_t
(since pthread_threadid_np() returns a uint64_t). Those extra 8 bytes
plus alignment padding shifted every following field, so parsers reading
the file by the spec misread code_size as the code address and failed to
resolve any Python frames.

Declare thread_id as uint32_t on all platforms and truncate the macOS
thread id when writing the record. The value is only informational.
Symbols are resolved by address, and not thread ids so truncation is
safe here.

* Use mach_absolute_time for macOS jitdump timestamps

On macOS the jitdump file is consumed by profilers such as samply, which
timestamp their samples using mach_absolute_time(). The jitdump events were
stamped with clock_gettime(CLOCK_MONOTONIC), a different clock domain that
keeps advancing while the system is asleep, so the JIT code mappings could be
off by days relative to the samples and no Python frame would resolve. Stamp
jitdump events with mach_absolute_time() on macOS so they share the sampler's
clock domain. Linux continues to use CLOCK_MONOTONIC to stay aligned with perf.

Exercise the -Xperf_jit (jitdump) backend through samply and assert that
Python frames resolve, exercising the binary jitdump path end to end.
Skipped when samply is not installed.
(cherry picked from commit 494f2e3c92)

Co-authored-by: Nazım Can Altınova <[email protected]>
2026-06-03 00:41:24 +00:00
1c2daa08fb [3.15] gh-150319: Replace all documentation which says "See PEP 585" (GH-150325) (#150808)
gh-150319: Replace all documentation which says "See PEP 585" (GH-150325)

* Replace all documentation which says "See PEP 585"

The following classes in the stdlib get simple updates:

- array.array
- asyncio.Future
- asyncio.Task
- collections.defaultdict
- collections.deque
- contextvars.ContextVar
- contextvars.Token
- ctypes.Array
- os.DirEntry
- re.Match
- re.Pattern
- string.templatelib.Interpolation
- string.templatelib.Template
- types.MappingProxyType
- queue.SimpleQueue
- weakref.ref

The following classes are documented publicly as functions, and are
therefore updated internally (`__class_getitem__.__doc__`) but not in the
public docs:

- functools.partial
- itertools.chain

The following builtin types have updates to `__class_getitem__.__doc__`
but not to any documentation pages:

- BaseExceptionGroup
- coroutines (from generators)
- dict
- enumerate
- frozendict
- frozenset
- generators (and async generators)
- list
- memoryview
- set
- slice
- tuple

Special cases:

- union objects are now documented as "supporting class-level []",
  rather than anything to do with generics.

- Templates might be generic over a single type (union, in theory) or
  over a TypeVarTuple. As this is not currently fully settled, it is
  marked with a comment and a mild hint that it is a single type is used
  (namely, "type" is singular rather than "types", plural)

* Apply suggestions from code review



* Correct several class getitem docs

And expand the text for tuples.



* Add notes on generic typing of builtins

* Fix typo in tuple.__class_getitem__ docstring

* Typo fix: malformed refs

Fix `generic` links which weren't marked as `:ref:`.

* Strike unnecessary docs on generic-ness



* Apply suggestions from code review

These are applied at both the originally indicated locations and in the
corresponding docstring definitions.



* Update Doc/library/re.rst



* Update Objects/enumobject.c



* Remove tuple generic doc in 'stdtypes' page

This is covered in more detail in the cross-linked typing documentation.
The other copy of this documentation -- in the docstring for
`tuple.__class_getitem__` -- is left in place.

* Fix whitespace around new doc of generics

Per review, do not introduce or remove whitespace such that section
breaks are altered by the introduction of doc on various generic types.

In most cases, this is a removal of an extra line.

In one case (Arrays), it is the reintroduction of a line.

Additionally, two other minor fixes are included:
- incorrect indent on 'defaultdicts'
- make `mappingproxy.__class_getitem__.__doc__` consistent with other
  mapping type generic docs



* Move placement of memoryview generic note

Previous placement was at the end of the main docstring, which is
consistent with other types but places it after a section on various
methods (which makes it read somewhat inconsistently). Moving it up
helps resolve.



* Ensure sphinxdoc does not start sentences lowercase

Lowercase class names at the start of sentences are marked out with the
`class` role. In the case of `deque`, documentation already refers to
these as `Deques`, so this form is preferred.

* Apply suggestions from code review



* Fix line endings and wrap more tightly

Line endings fixed by pre-commit ; also re-wrapped the MappingProxyType
text which was too long.

* Use 'ContextVars' style in sphinx doc

---------
(cherry picked from commit 50fe49c879)

Co-authored-by: Stephen Rosen <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
2026-06-02 20:40:52 +00:00