Commit graph

14603 commits

Author SHA1 Message Date
Stan Ulbrych
8e73feee5c
[3.13] gh-148801: Fix unbound C recursion in Element.__deepcopy__() (GH-148802) (#148843) 2026-06-08 20:14:48 +01:00
Miss Islington (bot)
619a12b2e5
[3.13] gh-150599: Prevent bz2 decompressor reuse after errors (GH-150600)
(cherry picked from commit 157a5df8cb)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-08 10:55:32 +01:00
Miss Islington (bot)
68250323fc
[3.13] gh-150913: Fix sqlite3.Blob validation for empty slice assignment (GH-150915) (GH-150925)
ass_subscript_slice() returned early when the computed slice length
was zero, bypassing validation performed for non-empty slices.
(cherry picked from commit fc9c4db130)

Co-authored-by: Jiseok CHOI <jiseok.dev@gmail.com>
2026-06-04 13:59:11 +00:00
Alex Waygood
7c5734c791
[3.13] gh-150319: Replace all documentation which says "See PEP 585" (#150325) (#150814)
gh-150319: Replace all documentation which says "See PEP 585" (#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

---------

Co-authored-by: Stephen Rosen <sirosen@globus.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <906600+JelleZijlstra@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-06-02 22:26:33 +00:00
Petr Viktorin
ba785b88ad
[3.13] gh-149079: Fix O(n^2) canonical ordering in unicodedata.normalize() (GH-149080) (#150780)
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 991224b1e8)

Co-authored-by: Seth Larson <seth@python.org>
Co-authored-by: ch4n3-yoon <ch4n3.yoon@gmail.com>
Co-authored-by: Seokchan Yoon <13852925+ch4n3-yoon@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-06-02 16:12:42 +00:00
Victor Stinner
b8ce8a38d1
[3.13] gh-149738: Fix segmentation fault bug in sqllite3 (#149754) (#150770)
gh-149738: Fix segmentation fault bug in sqllite3 (#149754)

Deleting the `row_factory` or `text_factory` attribute is no longer allowed.

(cherry picked from commit 60fdb3192b)

Co-authored-by: Sepehr Rasouli <sepehrrasouli06@gmail.com>
2026-06-02 14:52:30 +02:00
Miss Islington (bot)
ac0fe8a757
[3.13] gh-150372: Add missing null check on completer_word_break_characters in readline.c (GH-150251) (GH-150630)
(cherry picked from commit 56bd9ea676)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
2026-05-31 14:59:05 +03:00
Sergey B Kirpichev
70a4e191e6
[3.13] Correct frexp() docs for zero and non-finite numbers (GH-149753) (GH-150654)
0.5 <= abs(m) < 1 is only true for finite nonzero numbers
(cherry picked from commit 5b5ffce05c)
2026-05-31 07:58:24 +00:00
Miss Islington (bot)
4d91835af5
[3.13] gh-150406: Check result of PyThread_allocate_lock() for netdb_lock (GH-150407) (GH-150618)
(cherry picked from commit 1e18c45495)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
2026-05-30 19:56:46 +03:00
Serhiy Storchaka
68840510e3
[3.13] gh-150285: Fix too long docstrings in Argument Clinic code (GH-150338) (GH-150350) (GH-150473) (GH-150526)
(cherry picked from commit 49975a511f)
(cherry picked from commit cf73b17adf)
(cherry picked from commit 287c98f4cb)
2026-05-27 18:06:50 +00:00
Miss Islington (bot)
98a9ccbe39
[3.13] gh-149571: Fix the C implementation of Element.itertext() (GH-149929) (GH-150511)
It no longer emits text for comments and processing instructions.
(cherry picked from commit 7de4fcd445)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-27 10:49:54 +00:00
Serhiy Storchaka
96d66ac33b
[3.13] gh-150285: Fix too long docstrings in the io module (GH-150287) (GH-150458) (GH-150470)
(cherry picked from commit 36137e46a8)
(cherry picked from commit 160dc74122)
2026-05-26 10:29:28 +00:00
Serhiy Storchaka
b030936f33
[3.13] gh-150285: Fix too long docstrings in the sqlite3 module (GH-150290) (GH-150461) (GH-150471)
(cherry picked from commit 7168b02795)
(cherry picked from commit 0466560b31)
2026-05-26 10:11:11 +00:00
Serhiy Storchaka
56be4fb3d2
[3.13] gh-150285: Fix too long docstrings in the pyexpat module (GH-150294) (GH-150463) (GH-150468)
(cherry picked from commit ad1bb6c14c)
(cherry picked from commit 9da7923835)
2026-05-26 10:01:15 +00:00
Serhiy Storchaka
59cafbbeaf
[3.13] gh-150285: Fix too long docstrings in the curses module (GH-150286) (GH-150457) (GH-150469)
(cherry picked from commit e7f1216204)
(cherry picked from commit 4c0fe2d134)
2026-05-26 09:58:11 +00:00
Miss Islington (bot)
60d843777c
[3.13] gh-149449: Fix use-after-free in _PyUnicode_GetNameCAPI (GH-150323) (#150354)
gh-149449: Fix use-after-free in `_PyUnicode_GetNameCAPI` (GH-150323)
(cherry picked from commit 43c60ec2fd)

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2026-05-25 16:10:48 +05:30
Bénédikt Tran
e102378eca
[3.13] gh-142516: fix reference leaks in ssl.SSLContext objects (GH-143685) (GH-145075) (#148371)
Cherry picked from commits 3a2a686cc4
and 1decc7ee20 with minor amendments.
2026-05-24 11:43:03 +02:00
Shamil
e87baa8d24
[3.13] gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851) (#150079)
gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851)

User callbacks invoked during JSON encoding (e.g. the `default` callback or
a custom string encoder) can mutate or clear the dict or sequence being
encoded, invalidating borrowed references to items, keys, and values. Hold
strong references unconditionally while iterating.



(cherry picked from commit 235fa7244a)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-05-19 20:33:22 -07:00
Miss Islington (bot)
23fcb4824f
[3.13] gh-149983: Fix PyErr_NoMemory call without GIL in winconsoleio.c (GH-149984) (GH-150112)
(cherry picked from commit 3d2aa899ba)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2026-05-19 23:11:28 +02:00
Armaan Vakharia
44f314933c
[3.13] gh-149590: Remove faulthandler_traverse (GH-150023) (#150087)
`faulthandler_traverse` visits Python objects owned by `_PyRuntime`, not
by the module instance. With multi-phase init allowing multiple module
instances, each instance's GC traversal decrements `gc_refs` on the same
runtime-owned objects, driving it negative when two instances are
collected simultaneously.
(cherry picked from commit 56737483c2)
2026-05-19 15:04:13 +00:00
AN Long
5531c77d33
[3.13] gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (GH-149922) (#149954)
(cherry picked from commit acefff95ea)
2026-05-17 13:36:32 +00:00
Victor Stinner
782880ba23
[3.13] gh-149707: Fix compiler warning in _ctypes_test on strchr() (#149791) (#149867)
gh-149707: Fix compiler warning in _ctypes_test on strchr() (#149791)

Change my_strchr() return type to "const char*" (add "const").

Fix the compiler warning:

Modules/_ctypes/_ctypes_test.c: In function 'my_strchr':
Modules/_ctypes/_ctypes_test.c:451:12: warning: return discards
'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  451 |     return strchr(s, c);
      |            ^~~~~~

When using C23, strchr(text, ch) return type is "const char*" if text
type is "const char*".

(cherry picked from commit 5465b69255)
2026-05-15 11:32:58 +00:00
Miss Islington (bot)
6fff3e4bc6
[3.13] gh-149698: Update bundled expat to 2.8.1 (GH-149699) (#149827)
(cherry picked from commit f1a47e79fb)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-05-14 15:24:39 +00:00
Miss Islington (bot)
ae31e50d3f
[3.13] gh-149017: Upgrade bundled Expat to 2.8.0 (GH-149020) (#149099)
(cherry picked from commit 005555a3f0)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-05-14 16:00:07 +01:00
Stan Ulbrych
ea8c3e028b
[3.13] gh-145376: Fix various reference leaks (GH-145377) (#148661)
(cherry picked from commit bd13cc09fa)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-05-12 18:35:27 +00:00
Miss Islington (bot)
023ecbd01f
[3.13] gh-148093: Raise binascii.Error from binascii.a2b_uu() on empty input (GH-149077) (GH-149349)
Instead of reading past the end of the empty buffer.
(cherry picked from commit 0c6d2f64c0)

Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-05-04 10:06:25 +00:00
Serhiy Storchaka
0fd4fd4496
[3.13] gh-148529: Minor improvements of the struct module documentation (GH-148565) (GH-149072)
* Document that 's' and 'p' accept bytes and bytearray.
* Fix some footnotes.
* Clarify that "string" is a byte string.
* Fix the module docstring.
(cherry picked from commit 3e5a3cb2bd)
2026-04-27 20:22:47 +00:00
Stan Ulbrych
feafd5f69c
[3.13] gh-148735: Fix a UAF in Element.findtext() (GH-148738) (#148923)
(cherry picked from commit 0469e6d38d)
2026-04-25 10:38:14 +01:00
Miss Islington (bot)
813498411a
[3.13] gh-148484: Fix memory leak of iterator in array.array constructor (GH-148523) (GH-148679)
(cherry picked from commit afde75664e)

Co-authored-by: Gleb Popov <gvpopov.dev@gmail.com>
2026-04-23 16:00:47 +02:00
Miss Islington (bot)
95633d2aad
[3.13] gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (GH-148809) (#148836)
gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (GH-148809)
(cherry picked from commit 1274766d3c)

Co-authored-by: Seth Larson <seth@python.org>
2026-04-21 21:56:37 +05:30
Miss Islington (bot)
c3cf71c336
[3.13] gh-148395: Fix a possible UAF in {LZMA,BZ2,_Zlib}Decompressor (GH-148396) (#148479)
gh-148395: Fix a possible UAF in `{LZMA,BZ2,_Zlib}Decompressor` (GH-148396)

Fix dangling input pointer after `MemoryError` in _lzma/_bz2/_ZlibDecompressor.decompress
(cherry picked from commit 8fc66aef6d)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-13 01:35:24 +00:00
Miss Islington (bot)
8e369d3645
[3.13] gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106) (#148405)
gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106)

When a custom iterator calls next() on the same csv.reader from
within __next__, the inner iteration sets self->fields to NULL.
The outer iteration then crashes in parse_save_field() by passing
NULL to PyList_Append.

Add a guard after PyIter_Next() to detect that fields was set to
NULL by a re-entrant call, and raise csv.Error instead of crashing.
(cherry picked from commit 20994b1809)

Co-authored-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
2026-04-11 22:44:45 +00:00
Miss Islington (bot)
7fc8507f3d
[3.13] gh-146613: Fix re-entrant use-after-free in itertools._grouper (GH-147962) (#148011)
gh-146613: Fix re-entrant use-after-free in `itertools._grouper` (GH-147962)
(cherry picked from commit fc7a188fe7)

Co-authored-by: Ma Yukun <68433685+TheSkyC@users.noreply.github.com>
2026-04-07 12:24:54 +02:00
Ramin Farajpour Cami
4c8d6f4f68
[3.13] gh-144984: Fix crash in Expat's ExternalEntityParserCreate error paths (GH-144992) (#146142)
* gh-144984: Fix crash in Expat's `ExternalEntityParserCreate` error paths (#144992)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* gh-144984: Skip test under tracerefs (GH-146218)

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-04-07 12:22:22 +02:00
Miss Islington (bot)
df89a705d0
[3.13] gh-145883: Fix two heap-buffer-overflows in _zoneinfo (GH-145885) (#148086)
(cherry picked from commit fe9befc1ca)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-04 17:14:19 +01:00
Victor Stinner
01af34a364
[3.13] gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (#145901) (#147437)
The long_from_string_base() might return a small integer, when the
_pylong.py is used to do conversion.  Hence, we must be careful here to
not smash it "small int" bit by using the _PyLong_FlipSign().

Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit db5936c5b8)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-03-31 17:06:38 +02:00
Serhiy Storchaka
fc1c6446ce
[3.13] gh-146615: Fix format specifiers in extension modules (GH-146617) (GH-146652) (GH-146658)
(cherry picked from commit 1c396e1821)
(cherry picked from commit 58c7259133)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-03-31 10:59:06 +00:00
Serhiy Storchaka
def8ea08a1
[3.13] gh-146615: Fix format specifiers in test cextensions (GH-146618) (GH-146653)
(cherry picked from commit b7055533ab)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-03-31 08:38:59 +00:00
Miss Islington (bot)
472f1afa1c
[3.13] gh-146083: Upgrade bundled Expat to 2.7.5 (GH-146085) (#146604)
(cherry picked from commit e39d84a37d)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-03-29 18:50:07 +01:00
Miss Islington (bot)
6fdf084644
[3.13] gh-146090: fix memory management of internal sqlite3 callback contexts (GH-146569) (#146596)
gh-146090: fix memory management of internal `sqlite3` callback contexts (GH-146569)
(cherry picked from commit aa6680775d)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-03-29 15:14:58 +02:00
Bénédikt Tran
59f33e82ff
[3.13] gh-146080: fix a crash in SNI callbacks when the SSL object is gone (GH-146573) (#146598)
(cherry picked from commit 24db78c532)
2026-03-29 13:07:15 +00:00
Victor Stinner
04fe383602
[3.13] gh-146480: Add tests on _PyErr_SetKeyError() (#146486) (#146512)
gh-146480: Add tests on _PyErr_SetKeyError() (#146486)

(cherry picked from commit d4153a9f76)
2026-03-27 14:09:46 +01:00
Miss Islington (bot)
de1644cd40
[3.13] gh-146059: Call fast_save_leave() in pickle save_frozenset() (GH-146173) (#146474)
gh-146059: Call fast_save_leave() in pickle save_frozenset() (GH-146173)

Add more pickle tests: test also nested structures.
(cherry picked from commit 5c0dcb3e0d)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-27 08:47:53 +00:00
Miss Islington (bot)
2bb1ac2162
[3.13] gh-144837: Improve documentation for more collection methods (GH-144841) (GH-146484)
Use uniform standard signature syntax in the tutorial and in
the array and collections modules documentation.
(cherry picked from commit 17070f41d4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-03-26 19:52:07 +00:00
Victor Stinner
921515f603
[3.13] gh-145633: Fix struct.pack('f') on s390x (#146422) (#146461)
gh-145633: Fix struct.pack('f') on s390x (#146422)

Use PyFloat_Pack4() to raise OverflowError.
Add more tests on packing/unpacking floats.


(cherry picked from commit 8de70b31c5)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-03-26 11:45:10 +00:00
Miss Islington (bot)
5a4959b92c
[3.13] Fix unlikely potential reference leak in _locale._getdefaultlocale (GH-145250) (GH-145303)
It occurs in a code which perhaps never executed.
(cherry picked from commit 6ea84b2726)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-03-24 02:18:19 +00:00
Brij Kapadia
4e372077c5
[3.13] gh-144475: Fix reference management in partial_repr (GH-145362) (#145882)
(cherry picked from commit 671a953dd6)
2026-03-24 02:30:45 +01:00
Miss Islington (bot)
1f9958f909
[3.13] gh-145264: Do not ignore excess Base64 data after the first padded quad (GH-145267) (GH-146326) (GH-146348)
Base64 decoder (see binascii.a2b_base64(), base64.b64decode(), etc)
no longer ignores excess data after the first padded quad in non-strict
(default) mode.  Instead, in conformance with RFC 4648, it ignores the
pad character, "=", if it is present before the end of the encoded data.
(cherry picked from commit 4561f6418a)
(cherry picked from commit e31c551216)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-03-24 00:52:20 +01:00
Miss Islington (bot)
2f1e341b28
[3.13] gh-146245: Fix reference and buffer leaks via audit hook in socket module (GH-146248) (GH-146275)
(cherry picked from commit c30fae4bea)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2026-03-22 11:51:54 +00:00
AN Long
d513f9ef8f
[3.13] gh-129849: Add tests for Py_tp_bases (GH-143208) (#146226)
(cherry picked from commit 6f8867a676)
2026-03-21 15:22:45 +05:30