Commit Graph

7535 Commits

Author SHA1 Message Date
Serhiy Storchaka 5dac9c53cd
[3.11] gh-115618: Remove improper Py_XDECREFs in property methods (GH-115619) (GH-115621)
(cherry picked from commit 090dd21ab9)
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 11c582235d)

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 f1f8392432)

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 0e732d0997)

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 e7d5433f94)

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 2b15536fa9)
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 0e6e32fb84)
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 f08e52ccb0)
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 e1c295e3da)
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 ab86426a34)
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 3c70d467c1)

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 1d33d53780)
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 555be81026)

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 a781484c8e)
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 69621d1b09)

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 3ed8c88290)

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 58b6be3791)

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 50b4b15984)

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 65fb7c4055)

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 705487c655)

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 8d0f09b1be)

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 d71edbd1b7)
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 54dfa14c5a)
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 d9de079248)

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 cf89c16486.
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 401fdf9c85)

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 b1a74a182d)

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 94fc7706b7)

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 d7e7f79ca7)

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 88d565f32a)

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 935ef59321)

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 c8c6113398)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2022-11-18 08:10:55 -08:00
Miss Islington (bot) bbac9a8bcc
gh-99443: `descr_set_trampoline_call` return type should be `int` not `PyObject*` (GH-99444)
(cherry picked from commit bc390dd935)

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2022-11-16 15:50:50 -08:00
Miss Islington (bot) 47f4a18be0
gh-99181: fix except* on unhashable exceptions (GH-99192)
(cherry picked from commit c43714fbcd)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2022-11-08 01:58:45 -08:00
Miss Islington (bot) 20c258c692
gh-98852: Fix subscription of type aliases (GH-98920)
Fix subscription of type aliases containing bare generic types or types
like TypeVar: for example tuple[A, T][int] and tuple[TypeVar, T][int],
where A is a generic type, and T is a type variable.
(cherry picked from commit 0e15c31c7e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-11-01 01:01:28 -07:00
Dennis Sweeney 5efe2eead3
[3.11] gh-98783: Fix crashes when `str` subclasses are used in `_PyUnicode_Equal` (GH-98806) (#98871)
* gh-98783: Fix crashes when `str` subclasses are used in `_PyUnicode_Equal` (GH-98806)
(cherry picked from commit 76f989dc3e)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-10-30 14:30:08 -04:00
Miss Islington (bot) cfbc01fe48
obmalloc: Remove unused variable. (GH-98770)
(cherry picked from commit bded5edd9a)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2022-10-27 09:30:46 -07:00
Miss Islington (bot) 33cf0a604c
gh-97943: PyFunction_GetAnnotations should return a borrowed reference. (GH-97949)
(cherry picked from commit 6bfb0be804)

Co-authored-by: larryhastings <larry@hastings.org>
2022-10-06 13:03:32 -07:00