7541 Commits

Author SHA1 Message Date
Gregory P. Smith
0cd888b8d3
[3.11] gh-120384: gh-120298: Fix array-out-of-bounds & use after free list (GH-121345)
(cherry picked from commit 8334a1b55c93068f5d243852029baa83377ff6c9)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-10-31 15:19:07 +01:00
Miss Islington (bot)
313544eb03
[3.11] gh-127563: use dk_log2_index_bytes=3 in empty dicts (GH-127568) (GH-127813) (#135463)
[3.12] gh-127563: use `dk_log2_index_bytes=3` in empty dicts (GH-127568) (GH-127813)

This fixes a UBSan failure (unaligned zero-size memcpy) in `dictobject.c`.
(cherry picked from commit 9af96f440618304e7cc609c246e1f8c8b2d7a119)

(cherry picked from commit 320a1dcd97110598a4fe6ae1c0018cd3decc408f)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-16 14:51:04 +02:00
Serhiy Storchaka
73b3040f59
[3.11] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944) (GH-134341)
If the error handler is used, a new bytes object is created to set as
the object attribute of UnicodeDecodeError, and that bytes object then
replaces the original data. A pointer to the decoded data will became invalid
after destroying that temporary bytes object. So we need other way to return
the first invalid escape from _PyUnicode_DecodeUnicodeEscapeInternal().

_PyBytes_DecodeEscape() does not have such issue, because it does not
use the error handlers registry, but it should be changed for compatibility
with _PyUnicode_DecodeUnicodeEscapeInternal().
(cherry picked from commit 9f69a58623bd01349a18ba0c7a9cb1dad6a51e8e)
(cherry picked from commit 6279eb8c076d89d3739a6edb393e43c7929b429d)
(cherry picked from commit a75953b347716fff694aa59a7c7c2489fa50d1f5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-02 17:52:52 +02:00
Miss Islington (bot)
bccd1f691f
[3.11] gh-116714: Handle errors correctly in PyFloat_GetInfo (GH-116715) (#116723)
gh-116714: Handle errors correctly in `PyFloat_GetInfo` (GH-116715)
(cherry picked from commit fcd49b4f47f1edd9a2717f6619da7e7af8ea73cf)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-13 16:40:30 +03:00
Nikita Sobolev
f3a2b62bc1
[3.11] gh-110819: Fix ‘kind’ may be used uninitialized warning in longobject (GH-116599) (#116650)
(cherry picked from commit eb947cdc1374842a32fa82249ba3c688abf252dc)
2024-03-12 22:21:52 +03:00
Miss Islington (bot)
f068522a3a
[3.11] gh-116296: Fix refleak in reduce_newobj() corner case (GH-116297) (#116300)
(cherry picked from commit 17c4849981905fb1c9bfbb2b963b6ee12e3efb2c)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2024-03-04 10:04:21 +00:00
Serhiy Storchaka
5dac9c53cd
[3.11] gh-115618: Remove improper Py_XDECREFs in property methods (GH-115619) (GH-115621)
(cherry picked from commit 090dd21ab9379d6a2a6923d6cbab697355fb7165)
2024-02-17 21:47:32 +00:00
Donghee Na
1739efc57d
[3.11] gh-112087: Fix reduce logic for the empty reverse iterator for list (gh-115472) 2024-02-14 18:43:39 +00:00
Miss Islington (bot)
21799488bc
[3.11] gh-113560: Improve docstrings for set.issubset() and set.issuperset() (GH-113562) (GH-114643)
(cherry picked from commit 11c582235d86b6020710eff282eeb381a7bf7bb7)

Co-authored-by: Charlie Zhao <zhaoyu_hit@qq.com>
2024-01-27 11:21:24 +00:00
Alex Waygood
c828dbc196
[3.11] Document the co_lines method on code objects (#113682) (#113687)
(cherry-picked from commit f1f839243251fef7422c31d6a7c3c747e0b5e27c)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2024-01-03 19:59:10 +00:00
Hugo van Kemenade
a39131ed8c
[3.11] gh-110383: Improve accuracy of str.split() and str.rsplit() docstrings (GH-113355) (#113380)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-12-22 00:43:38 -07:00
Miss Islington (bot)
7e89dd9926
[3.11] gh-112625: Protect bytearray from being freed by misbehaving iterator inside bytearray.join (GH-112626) (GH-112694)
(cherry picked from commit 0e732d0997cff08855d98c17af4dd5527f10e419)

Co-authored-by: chilaxan <chilaxan@gmail.com>
2023-12-04 10:37:25 +02:00
Nikita Sobolev
6c51c84b39
[3.11] gh-112266: Remove (if defined) part from __dict__ and __weakref__ docstrings (GH-112268) (#112276) 2023-11-20 09:04:38 +00:00
Savannah Ostrowski
12c7e5071c
[3.11] GH-94438: Restore ability to jump over None tests (GH-111338)
(cherry picked from commit 6640f1d)
2023-10-25 20:47:16 +00:00
Shantanu
784207ecf3
[3.11] gh-108915: Removes extra backslashes in str.split docstring (GH-109044) (#109062)
[3.11] gh-108915: Removes extra backslashes in str.split docstring (GH-109044).
(cherry picked from commit e7d5433f944a5725aa82595f9251abfc8a63d333)

Co-authored-by: Daniel Weiss <134341009+justdan6@users.noreply.github.com>
2023-09-07 06:07:57 +00:00
Serhiy Storchaka
b9fc536399
[3.11] gh-107913: Fix possible losses of OSError error codes (GH-107930) (GH-108524)
Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be
called immediately after using the C API which sets errno or the Windows
error code.
(cherry picked from commit 2b15536fa94d07e9e286826c23507402313ec7f4)
2023-08-27 12:18:58 +00:00
Serhiy Storchaka
edaa0db93e
[3.11] gh-86457: Fix signature for code.replace() (GH-23199) (GH-107746)
Also add support of @text_signature in Argument Clinic.
(cherry picked from commit 0e6e32fb84b2f7cb668e0b9927637587081e38cd)
2023-08-09 06:12:02 +00:00
Miss Islington (bot)
46cae02085
[3.11] gh-106092: Fix use-after-free crash in frame_dealloc (GH-106875) (#107533) 2023-08-01 11:21:08 +01:00
Serhiy Storchaka
b8b3e6afc0
[3.11] gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (GH-99613) (GH-107224)
Previously *consumed was not set in this case.
(cherry picked from commit f08e52ccb027f6f703302b8c1a82db9fd3934270)
2023-07-25 14:15:14 +03:00
Serhiy Storchaka
fb04874053
[3.11] gh-106719: Fix __annotations__ getter and setter in the type and module types (GH-106720) (GH-106850)
No longer suppress arbitrary errors. Simplify the code.
(cherry picked from commit e1c295e3da9ff5a3eb6b009a1f821d80e564ac87)
2023-07-18 10:19:45 +03:00
Dennis Sweeney
d488970ae6
[3.11] gh-105235: Prevent reading outside buffer during mmap.find() (… (#106710)
[3.11] gh-105235: Prevent reading outside buffer during mmap.find() (GH-105252)

* Add a special case for s[-m:] == p in _PyBytes_Find

* Add tests for _PyBytes_Find

* Make sure that start <= end in mmap.find.
(cherry picked from commit ab86426a3472ab68747815299d390b213793c3d1)
2023-07-14 22:17:09 -04:00
Miss Islington (bot)
8623812fdc
[3.11] Fix possible refleak in CodeType.replace() (GH-106243) (GH-106245)
Fix possible refleak in CodeType.replace() (GH-106243)

A reference to c_code was leaked if PySys_Audit() failed.
(cherry picked from commit 3c70d467c148875f2ce17bacab8909ecc3e9fc1d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-06-29 21:41:18 +03:00
Serhiy Storchaka
dbe416b82b
[3.11] gh-106033: Get rid of new occurrences of PyDict_GetItem and Py… (#106040)
[3.11] gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr (GH-106034)

These functions are broken by design because they discard any exceptions raised
inside, including MemoryError and KeyboardInterrupt.  They should not be
used in new code..
(cherry picked from commit 1d33d5378058671bfabb6f4d4b5bfd4726973ff9)
2023-06-24 16:41:02 -07:00
Miss Islington (bot)
91877478ed
[3.11] gh-105375: Improve error handling in PyUnicode_BuildEncodingMap() (GH-105491) (#105662)
Bail on first error to prevent exceptions from possibly being overwritten.
(cherry picked from commit 555be81026fe1205d16c02f6321221381174cd07)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-11 20:01:52 +00:00
Brandt Bucher
4ade7c3369
[3.11] Fix refleak in super_descr_get (GH-104440)
(cherry picked from commit a781484c8e9834538e5ee7b9e2e6bec7b679e033)
2023-05-12 22:29:02 +00:00
Brandt Bucher
b90c922f3f
[3.11] GH-94841: Fix usage of Py_ALWAYS_INLINE (GH-104439) 2023-05-12 22:06:29 +00:00
Lysandros Nikolaou
a09d3901a5
[3.11] gh-96670: Raise SyntaxError when parsing NULL bytes (GH-97594) (#104195) 2023-05-07 11:12:04 +01:00
Miss Islington (bot)
15ffcf76e1
[3.11] gh-104018: remove unused format "z" handling in string formatfloat() (GH-104107) (#104260)
gh-104018: remove unused format "z" handling in string formatfloat() (GH-104107)

This is a cleanup overlooked in PR GH-104033.
(cherry picked from commit 69621d1b09c996e43a1e13d2fa4c317d3dd4d738)

Co-authored-by: John Belmonte <john@neggie.net>
2023-05-07 05:06:06 +00:00
Irit Katriel
5386730cdd
[3.11] gh-103590: do not wrap a single exception raised from a try-except* (#104094) 2023-05-02 19:24:02 +01:00
Miss Islington (bot)
10db28bfcf
[3.11] gh-104018: disallow "z" format specifier in %-format of byte strings (GH-104033) (#104058)
gh-104018: disallow "z" format specifier in %-format of byte strings (GH-104033)

PEP-0682 specified that %-formatting would not support the "z" specifier,
but it was unintentionally allowed for bytes. This PR makes use of the "z"
flag an error for %-formatting in a bytestring.

Issue: GH-104018

---------

(cherry picked from commit 3ed8c882902a6982fd67e898a5b8a2d619fb5ddf)

Co-authored-by: John Belmonte <john@neggie.net>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-05-01 20:18:29 +00:00
Miss Islington (bot)
c8de883bcb
[3.11] gh-99184: Bypass instance attribute access in repr of weakref.ref (GH-99244) (#103789)
gh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (GH-99244)
(cherry picked from commit 58b6be3791f55ceb550822ffd8664eca10fd89c4)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-04-24 19:58:55 +00:00
Miss Islington (bot)
e715da6db1
gh-87864: Use correct function definition syntax in the docs (GH-103312)
(cherry picked from commit 50b4b1598411ed393f47ce7f4fffbe5b9063cd42)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-04-11 07:19:33 -07:00
Miss Islington (bot)
f967aee4fb
gh-102701: Fix overflow in dictobject.c (GH-102750)
(cherry picked from commit 65fb7c4055f280caaa970939d16dd947e6df8a8d)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2023-03-17 07:54:18 -07:00
Miss Islington (bot)
06a3bb8c94
gh-101892: Fix SystemError when a callable iterator call exhausts the iterator (GH-101896)
(cherry picked from commit 705487c6557c3d8866622b4d32528bf7fc2e4204)

Co-authored-by: Raj <51259329+workingpayload@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-03-04 06:46:17 -08:00
Miss Islington (bot)
64d3715de8
gh-101765: unicodeobject: use Py_XDECREF correctly (GH-102283)
(cherry picked from commit 8d0f09b1beafd95763a5da53acc58dac0bd63a53)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-02-26 15:09:18 -08:00
Jelle Zijlstra
b36c49899b
[3.11] gh-101765: Fix refcount issues in list and unicode pickling (GH-102265) (#102268)
(cherry picked from commit d71edbd1b7437706519a9786211597d95934331a)
2023-02-25 16:38:19 -08:00
Ionite
5d461225a5
[3.11] gh-101765: Fix SystemError / segmentation fault in iter __reduce__ when internal access of builtins.__dict__ exhausts the iterator (GH-101769) (#102228)
(cherry picked from commit 54dfa14c5a94b893b67a4d9e9e403ff538ce9023)
2023-02-24 19:49:59 -08:00
Erlend E. Aasland
c5c12381b3
[3.11] GH-101696: invalidate type version tag in _PyStaticType_Dealloc (GH-101697) (#101722)
[3.11] GH-101696: invalidate type version tag in `_PyStaticType_Dealloc` (GH-101697).
(cherry picked from commit d9de0792482d2ded364b0c7d2867b97a5da41b12)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-02-11 14:00:42 +05:30
Łukasz Langa
955ba2839b
[3.11] gh-101072: support default and kw default in PyEval_EvalCodeEx for 3.11+ (GH-101127) (#101636)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Matthieu Dartiailh <m.dartiailh@gmail.com>
2023-02-07 13:36:35 +00:00
Mark Dickinson
358b02dac4
[3.11] gh-101266: Revert fix __sizeof__ for subclasses of int (#101638)
Revert "[3.11] gh-101266: Fix __sizeof__ for subclasses of int (GH-101394) (#101579)"

This reverts commit cf89c16486a4cc297413e17d32082ec4f389d725.
2023-02-07 11:44:43 +00:00
Mark Dickinson
cf89c16486
[3.11] gh-101266: Fix __sizeof__ for subclasses of int (GH-101394) (#101579)
Fix the behaviour of the `__sizeof__` method (and hence the results returned
by `sys.getsizeof`) for subclasses of `int`. Previously, `int` subclasses gave
identical results to the `int` base class, ignoring the presence of the instance
dictionary.

(Manual backport of #101394 to the Python 3.11 branch.)
2023-02-05 12:18:56 +00:00
Miss Islington (bot)
d2aaf818ae
[3.11] gh-101037: Fix potential memory underallocation for zeros of int subtypes (GH-101038) (#101219)
gh-101037: Fix potential memory underallocation for zeros of int subtypes (GH-101038)

This PR fixes object allocation in long_subtype_new to ensure that there's at least one digit in all cases, and makes sure that the value of that digit is copied over from the source long.

Needs backport to 3.11, but not any further: the change to require at least one digit was only introduced for Python 3.11.

Fixes GH-101037.
(cherry picked from commit 401fdf9c851eb61229250ebffa942adca99b36d1)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2023-01-21 10:54:09 +00:00
Miss Islington (bot)
63690e9af8
gh-101056: Fix memory leak in formatfloat() in bytesobject.c (GH-101057)
(cherry picked from commit b1a74a182d8762bda51838401ac92b6ebad9632a)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-01-16 03:12:23 -08:00
Nikita Sobolev
855b1a935e
[3.11] GH-100942: Fix incorrect cast in property_copy(). (GH-100965). (#101008)
(cherry picked from commit 94fc7706b7bc3d57cdd6d15bf8e8c4499ae53a69)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
2023-01-15 12:38:25 +05:30
Miss Islington (bot)
50409a2968
[3.11] gh-100637: Fix int and bool __sizeof__ calculation to include the 1 element ob_digit array for 0 and False (GH-100663) (#100717)
gh-100637: Fix int and bool __sizeof__ calculation to include the 1 element ob_digit array for 0 and False (GH-100663)

Fixes behaviour where int (and subtypes like bool) __sizeof__ under-reports true size as it did not take into account the size 1 `ob_digit` array for the zero int.

(cherry picked from commit d7e7f79ca7c2029e46a06d21a7a5abea631b5d13)

Co-authored-by: Ionite <dev@ionite.io>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2023-01-03 17:59:40 +00:00
Bill Fisher
57e727af3f
[3.11] gh-99110: Initialize frame->previous in init_frame to fix segmentation fault (GH-100182) (#100478)
(cherry picked from commit 88d565f32a709140664444c6dea20ecd35a10e94)

Co-authored-by: Bill Fisher <william.w.fisher@gmail.com>
2022-12-24 11:17:10 +05:30
Miss Islington (bot)
17bc55e043
clarify the 4300-digit limit on int-str conversion (GH-100175)
(cherry picked from commit 935ef593211a627526b2b869ce1fc2a5e67e6cdd)

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
2022-12-12 04:06:48 -08:00
Ken Jin
9e38553132
[3.11] gh-99886: Fix crash when freeing objects with managed dictionaries (#99902)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-12-04 14:41:23 +08:00
Victor Stinner
9707bf228e
gh-99845: _PyObject_DictPointer(): fix dictoffset cast (#99922)
Cast size_t to Py_ssize_t, rather than casting it to long. On 64-bit
Windows, long is 32-bit whereas Py_ssize_t is 64-bit.
2022-12-01 14:07:58 +01:00
Miss Islington (bot)
82ab9e6b79
gh-99553: fix bug where an ExceptionGroup subclass can wrap a BaseException (GH-99572)
(cherry picked from commit c8c6113398ee9a7867fe9b08bc539cceb61e2aaa)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2022-11-18 08:10:55 -08:00