[3.14] gh-129011: Update docs for Raw I/O read, readinto, and write (GH-135328) (#150958)
gh-129011: Update docs for Raw I/O read, readinto, and write (GH-135328)
Update `RawIOBase` and `FileIO` documentation to match implementation
behavior around `.read`, `.readinto`, `.readall` and `.write`.
In particular:
- They may make more than one system call (PEP-475)
- Add warnings if `.write()` requires a wrapping retry loop (see: gh-126606)
- "Raw I/O" `.write`` may not write all bytes
- `buffering=0` example results in a "Raw I/O"
(cherry picked from commit e4db68b9c990ed1bb7562094bee2e73f4450d42b)
ass_subscript_slice() returned early when the computed slice length
was zero, bypassing validation performed for non-empty slices.
(cherry picked from commit fc9c4db1302f8be7527e70cf0938b629985a1d72)
[3.14] Correct Stable ABI documentation for METH_FASTCALL (GH-149593) (GH-150852)
The current documentation says:
>
> METH_FASTCALL
> Part of the Stable ABI since version 3.7.
>
> [...]
>
> Added in version 3.7.
>
> Changed in version 3.10: METH_FASTCALL is now part of the stable ABI.
so is contradictory about when it was added to the Stable ABI. Looking at the header it seems like 3.10 is right.
(cherry picked from commit 58beae7319c58d850184d621d6635de23f71a229)
[3.14] gh-91099: fix[imaplib]: call Exception with string instance (GH-31823) (#150810)
* bpo-46943: fix[imaplib]: call Exception with string instance
Adjust the behavior of 'login' to be similar to `authenticate()`,
where self.error is called with a str() instance.
(cherry picked from commit 29805f00a1b65163230d17584c30e2b955086abb)
Co-authored-by: Florian Best <spaceone@users.noreply.github.com> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
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:
- 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.
BufferedRandom does not inherit from BufferedReader and BufferedWriter
in the C implementation.
(cherry picked from commit 551bc2cb5ed4719c35ca3ea0f320167dd750389e)
[3.14] gh-89554: Document _thread.LockType as a class (GH-150684) (#150784)
gh-89554: Document _thread.LockType as a class (GH-150684)
_thread.LockType is a class (the type of lock objects), but was documented
with the ".. data::" directive, so ":class:" cross-references to it cannot
resolve against a py:class target.
Switch the entry to ".. class::", move it next to the lock methods, and
document acquire(), release() and locked() as methods of the class. Keep
the old _thread.lock.* URL fragments working with raw HTML anchors.
(cherry picked from commit e37ce569773b5e4e5c0e6042d4adfde2e9608f13)
Co-authored-by: Bernát Gábor <gaborjbernat@gmail.com>
[3.14] gh-149079: Fix O(n^2) canonical ordering in unicodedata.normalize() (GH-149080)
Replace the insertion sort used for canonical ordering of combining
characters with a hybrid approach: insertion sort for short runs (< 20)
and counting sort for longer runs, reducing worst-case complexity from
O(n^2) to O(n). This prevents denial of service via crafted Unicode
strings with many combining characters in alternating CCC order.
(cherry picked from commit 991224b1e8311c85f198f6dd8208bf8cff7fc26f)
[3.14] gh-89554: Document weakref type objects as classes (GH-150678) (GH-150759)
Use the "class" directive instead of "data" for ReferenceType,
ProxyType and CallableProxyType.
(cherry picked from commit 10c421970beca89df92a918f2247fb8850d3b6cc)
Co-authored-by: Bernát Gábor <gaborjbernat@gmail.com>
[3.14] gh-89554: Document NoneType, NotImplementedType and EllipsisType as classes (GH-150682) (GH-150756)
Always use the directive and the role "class" instead of "data" for
NoneType, NotImplementedType and EllipsisType.
(cherry picked from commit e40190e104c81b61cdc6f71a391e28de53bbc1d8)
Co-authored-by: Bernát Gábor <gaborjbernat@gmail.com>
[3.14] gh-150644: Tag Apple system log messages as public. (GH-150645) (#150739)
macOS 26 changed the default visibility of "dynamic" system messages. This
changes the logging strategy to tag all messages as "public" so they are
visible in the system log without special configuration.
(cherry picked from commit 71fc4c66d3e675a5481b6b76e6c707c9b6f1e0e0)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Victor Stinner [Mon, 1 Jun 2026 15:23:15 +0000 (17:23 +0200)]
[3.14] gh-150436: Skip subprocess test on STATUS_DLL_INIT_FAILED (#150704) (#150715)
gh-150436: Skip subprocess test on STATUS_DLL_INIT_FAILED (#150704)
If a subprocess spawned with CREATE_NEW_CONSOLE creation flag fails
with STATUS_DLL_INIT_FAILED return code, skip the test. It's likely a
memory allocation failure in the desktop heap memory which caused the
DLL init failure.
Serhiy Storchaka [Sat, 30 May 2026 10:52:00 +0000 (13:52 +0300)]
[3.14] gh-149489: Fix ElementTree serialization to HTML (GH-149490) (GH-150596)
* The content of elements "xmp", "iframe", "noembed", "noframes",
and "plaintext" is no longer escaped.
* The "plaintext" element no longer have the closing tag.
[3.14] gh-150046: Fix `test_add_python_opts` to ignore `PYTHON*` env vars (GH-150089) (#150562)
gh-150046: Fix `test_add_python_opts` to ignore `PYTHON*` env vars (GH-150089)
Avoid the runtime environment from affecting the tests' behaviours,
which notably checks the warning filters which can be controlled by
various PYTHON environment variables.
(cherry picked from commit ef2246f788832a64ba7c5215c8e72f8e539e59b4)
ThreadingMock._increment_mock_call() was not thread-safe.
Multiple threads calling the mock simultaneously could lose
increments due to race conditions on call_count and other
attributes.
Fix by overriding _increment_mock_call in ThreadingMixin
and wrapping it with the existing _mock_calls_events_lock.
(cherry picked from commit 388e023fe1197c1ffed374520ed45df4ac72b8f5)
[3.14] gh-148557: Use em-config to locate trampoline clang (GH-148556) (#150482)
When CC is wrapped by ccache, the Emscripten trampoline rule cannot derive the
matching clang path by treating CC as a single executable path. Query the active
LLVM toolchain path with em-config instead.
(cherry picked from commit 1310d2c25242041f0a218012426fba14e756eef8)
[3.14] gh-149902: Remove dead packaging docs link and add a new section for external resources (GH-150030) (#150240)
Co-authored-by: Mia Albert <micha@2231puppy.tech> Co-authored-by: Stan Ulbrych <stan@python.org> Co-authored-by: Ned Batchelder <ned@nedbatchelder.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
[3.14] gh-137571: Protect against possible UnboundLocalError in gzip._GzipReader.read() (GH-150222) (GH-150230)
This has not been observed in practice, but we cannot be 100% sure that
it will not happen with some weird gzip data.
(cherry picked from commit 28eac9a7263ad8dcfa9b536aa238549131857e0f)
Jelle Zijlstra [Fri, 22 May 2026 04:46:40 +0000 (21:46 -0700)]
[3.14] gh-149995: Update typing.py docstrings and documentation (#150216)
[3.14] gh-149995: Update typing.py docstrings and documentation (GH-149996)
Some of these docstrings read as if they were written when typing.py was
first written, and things have evolved since then.
A few motivations:
- Call protocols protocols instead of ABCs. They are also ABCs, but the fact
they are protocols is more relevant to typing.
- Avoid recommending direct use of .__annotations__ and steer users to
annotationlib instead.
- For TypedDict, mention NotRequired before total=False since it is more
general and probably more frequently useful.
- For overloads, mention runtime use first instead of stub use. I think early on
there was talk of allowing overload only in stubs, but it is now heavily used at
runtime too and that's more likely to be relevant to users.
(cherry picked from commit f159419ae2ef1aebbd90ce9427b55e27738c960c)
[3.14] gh-148294: Make configure find g++ correctly (GH-150211)
The `AC_PATH_TOOL` calls had included a duplicated argument, causing a "`PATH`"
consisting of `notfound` to be searched instead of `$PATH`.
(cherry picked from commit c613f72eeef83340cb369287f7c1a195e086d1d5)
Victor Stinner [Thu, 21 May 2026 16:41:26 +0000 (18:41 +0200)]
[3.14] gh-139808: Add branch protections for aarch64 in asm_trampoline.S (#130864) (#150189)
gh-139808: Add branch protections for aarch64 in asm_trampoline.S (#130864)
Apply protection against ROP/JOP attacks for aarch64 on asm_trampoline.S.
The BTI flag must be applied in assembler sources for this class
of attacks to be mitigated on newer aarch64 processors.
See also:
https://sourceware.org/annobin/annobin.html/Test-branch-protection.html
and
https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/enabling-pac-and-bti-on-aarch64
The 3.14 backport makes Python/jit_unwind.c changes in
Python/perf_jit_trampoline.c.
Co-authored-by: Caleb <23644849+ctrlaltf2@users.noreply.github.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Emma Smith <emma@emmatyping.dev> Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>