summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* [3.11] gh-86457: Fix signature for code.replace() (GH-23199) (GH-107746)Serhiy Storchaka2023-08-092-49/+43
| | | | Also add support of @text_signature in Argument Clinic. (cherry picked from commit 0e6e32fb84b2f7cb668e0b9927637587081e38cd)
* [3.11] gh-106092: Fix use-after-free crash in frame_dealloc (GH-106875) ↵Miss Islington (bot)2023-08-011-6/+7
| | | | (#107533)
* [3.11] gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data ↵Serhiy Storchaka2023-07-251-0/+3
| | | | | | | (GH-99613) (GH-107224) Previously *consumed was not set in this case. (cherry picked from commit f08e52ccb027f6f703302b8c1a82db9fd3934270)
* [3.11] gh-106719: Fix __annotations__ getter and setter in the type and ↵Serhiy Storchaka2023-07-182-48/+33
| | | | | | module types (GH-106720) (GH-106850) No longer suppress arbitrary errors. Simplify the code. (cherry picked from commit e1c295e3da9ff5a3eb6b009a1f821d80e564ac87)
* [3.11] gh-105235: Prevent reading outside buffer during mmap.find() (… ↵Dennis Sweeney2023-07-151-2/+19
| | | | | | | | | | | | (#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)
* [3.11] Fix possible refleak in CodeType.replace() (GH-106243) (GH-106245)Miss Islington (bot)2023-06-291-0/+1
| | | | | | | | 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>
* [3.11] gh-106033: Get rid of new occurrences of PyDict_GetItem and Py… ↵Serhiy Storchaka2023-06-241-16/+15
| | | | | | | | | | (#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)
* [3.11] gh-105375: Improve error handling in PyUnicode_BuildEncodingMap() ↵Miss Islington (bot)2023-06-111-12/+17
| | | | | | | | (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>
* [3.11] Fix refleak in super_descr_get (GH-104440)Brandt Bucher2023-05-121-1/+3
| | | (cherry picked from commit a781484c8e9834538e5ee7b9e2e6bec7b679e033)
* [3.11] GH-94841: Fix usage of Py_ALWAYS_INLINE (GH-104439)Brandt Bucher2023-05-121-1/+1
|
* [3.11] gh-96670: Raise SyntaxError when parsing NULL bytes (GH-97594) (#104195)Lysandros Nikolaou2023-05-071-10/+19
|
* [3.11] gh-104018: remove unused format "z" handling in string formatfloat() ↵Miss Islington (bot)2023-05-072-5/+0
| | | | | | | | | | (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>
* [3.11] gh-103590: do not wrap a single exception raised from a try-except* ↵Irit Katriel2023-05-021-1/+6
| | | | (#104094)
* [3.11] gh-104018: disallow "z" format specifier in %-format of byte strings ↵Miss Islington (bot)2023-05-011-1/+0
| | | | | | | | | | | | | | | | | | (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>
* [3.11] gh-99184: Bypass instance attribute access in `repr` of `weakref.ref` ↵Miss Islington (bot)2023-04-241-4/+1
| | | | | | | | (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>
* gh-87864: Use correct function definition syntax in the docs (GH-103312)Miss Islington (bot)2023-04-111-4/+4
| | | | | (cherry picked from commit 50b4b1598411ed393f47ce7f4fffbe5b9063cd42) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-102701: Fix overflow in dictobject.c (GH-102750)Miss Islington (bot)2023-03-171-1/+1
| | | | | (cherry picked from commit 65fb7c4055f280caaa970939d16dd947e6df8a8d) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* gh-101892: Fix `SystemError` when a callable iterator call exhausts the ↵Miss Islington (bot)2023-03-041-2/+2
| | | | | | | | 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>
* gh-101765: unicodeobject: use Py_XDECREF correctly (GH-102283)Miss Islington (bot)2023-02-261-1/+1
| | | | | (cherry picked from commit 8d0f09b1beafd95763a5da53acc58dac0bd63a53) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* [3.11] gh-101765: Fix refcount issues in list and unicode pickling ↵Jelle Zijlstra2023-02-262-1/+11
| | | | | (GH-102265) (#102268) (cherry picked from commit d71edbd1b7437706519a9786211597d95934331a)
* [3.11] gh-101765: Fix SystemError / segmentation fault in iter `__reduce__` ↵Ionite2023-02-257-23/+66
| | | | | when internal access of `builtins.__dict__` exhausts the iterator (GH-101769) (#102228) (cherry picked from commit 54dfa14c5a94b893b67a4d9e9e403ff538ce9023)
* [3.11] GH-101696: invalidate type version tag in `_PyStaticType_Dealloc` ↵Erlend E. Aasland2023-02-111-0/+2
| | | | | | | | (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>
* [3.11] gh-101072: support default and kw default in PyEval_EvalCodeEx for ↵Łukasz Langa2023-02-071-2/+4
| | | | | | 3.11+ (GH-101127) (#101636) Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Matthieu Dartiailh <m.dartiailh@gmail.com>
* [3.11] gh-101266: Revert fix __sizeof__ for subclasses of int (#101638)Mark Dickinson2023-02-072-8/+9
| | | | | Revert "[3.11] gh-101266: Fix __sizeof__ for subclasses of int (GH-101394) (#101579)" This reverts commit cf89c16486a4cc297413e17d32082ec4f389d725.
* [3.11] gh-101266: Fix __sizeof__ for subclasses of int (GH-101394) (#101579)Mark Dickinson2023-02-052-9/+8
| | | | | | | | 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.)
* [3.11] gh-101037: Fix potential memory underallocation for zeros of int ↵Miss Islington (bot)2023-01-211-0/+5
| | | | | | | | | | | | | | 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>
* gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (GH-101057)Miss Islington (bot)2023-01-161-1/+3
| | | | | (cherry picked from commit b1a74a182d8762bda51838401ac92b6ebad9632a) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.11] GH-100942: Fix incorrect cast in property_copy(). (GH-100965). (#101008)Nikita Sobolev2023-01-151-3/+4
| | | | | (cherry picked from commit 94fc7706b7bc3d57cdd6d15bf8e8c4499ae53a69) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
* [3.11] gh-100637: Fix int and bool __sizeof__ calculation to include the 1 ↵Miss Islington (bot)2023-01-031-1/+4
| | | | | | | | | | | | 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>
* [3.11] gh-99110: Initialize frame->previous in init_frame to fix ↵Bill Fisher2022-12-241-0/+1
| | | | | | | segmentation fault (GH-100182) (#100478) (cherry picked from commit 88d565f32a709140664444c6dea20ecd35a10e94) Co-authored-by: Bill Fisher <william.w.fisher@gmail.com>
* clarify the 4300-digit limit on int-str conversion (GH-100175)Miss Islington (bot)2022-12-121-2/+2
| | | | | (cherry picked from commit 935ef593211a627526b2b869ce1fc2a5e67e6cdd) Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
* [3.11] gh-99886: Fix crash when freeing objects with managed dictionaries ↵Ken Jin2022-12-041-3/+5
| | | | | (#99902) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-99845: _PyObject_DictPointer(): fix dictoffset cast (#99922)Victor Stinner2022-12-011-1/+2
| | | | 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.
* gh-99553: fix bug where an ExceptionGroup subclass can wrap a BaseException ↵Miss Islington (bot)2022-11-181-1/+13
| | | | | | | (GH-99572) (cherry picked from commit c8c6113398ee9a7867fe9b08bc539cceb61e2aaa) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* gh-99443: `descr_set_trampoline_call` return type should be `int` not ↵Miss Islington (bot)2022-11-161-1/+1
| | | | | | | `PyObject*` (GH-99444) (cherry picked from commit bc390dd93574c3c6773958c6a7e68adc83d0bf3f) Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
* gh-99181: fix except* on unhashable exceptions (GH-99192)Miss Islington (bot)2022-11-081-17/+26
| | | | | (cherry picked from commit c43714fbcdb9bb0927872d6ebf5697edd2e2a1e9) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* gh-98852: Fix subscription of type aliases (GH-98920)Miss Islington (bot)2022-11-011-0/+7
| | | | | | | | 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 0e15c31c7e9907fdbe38a3f419b669fed5bb3b33) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.11] gh-98783: Fix crashes when `str` subclasses are used in ↵Dennis Sweeney2022-10-301-2/+2
| | | | | | | | `_PyUnicode_Equal` (GH-98806) (#98871) * gh-98783: Fix crashes when `str` subclasses are used in `_PyUnicode_Equal` (GH-98806) (cherry picked from commit 76f989dc3e668d15b3ec9a90bf6530276530acac) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* obmalloc: Remove unused variable. (GH-98770)Miss Islington (bot)2022-10-271-3/+1
| | | | | (cherry picked from commit bded5edd9abf7ae6b2874916d70ec29ad209217c) Co-authored-by: Benjamin Peterson <benjamin@python.org>
* gh-97943: PyFunction_GetAnnotations should return a borrowed reference. ↵Miss Islington (bot)2022-10-061-2/+5
| | | | | | | (GH-97949) (cherry picked from commit 6bfb0be80486c614cd60dce44c9fe7b3e6c76e3b) Co-authored-by: larryhastings <larry@hastings.org>
* gh-95196: Disable incorrect pickling of the C implemented classmethod ↵Miss Islington (bot)2022-10-051-1/+1
| | | | | | | descriptors (GH-96383) (cherry picked from commit 77f0249308de76401bf4f3c6a057789c92f862d1) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.11] GH-97779: Ensure that *all* frame objects are backed by "complete" ↵Miss Islington (bot)2022-10-052-4/+34
| | | | | | | frames (GH-97886) (cherry picked from commit 0ff8fd65838f9f9ed90d7a055d26a2ce9fc0ce85) Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
* gh-97591: In `Exception.__setstate__()` acquire strong references before ↵Miss Islington (bot)2022-10-021-1/+7
| | | | | | | calling `tp_hash` slot (GH-97700) (cherry picked from commit d63943860974f232b5f027dc6535d25d1b4d8fc0) Co-authored-by: Ofey Chan <ofey206@gmail.com>
* gh-97616: list_resize() checks for integer overflow (GH-97617)Miss Islington (bot)2022-09-281-2/+8
| | | | | | | | | | | Fix multiplying a list by an integer (list *= int): detect the integer overflow when the new allocated length is close to the maximum size. Issue reported by Jordan Limor. list_resize() now checks for integer overflow before multiplying the new allocated length by the list item size (sizeof(PyObject*)). (cherry picked from commit a5f092f3c469b674b8d9ccbd4e4377230c9ac7cf) Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-95778: Mention sys.set_int_max_str_digits() in error message (GH-96874)Miss Islington (bot)2022-09-161-2/+2
| | | | | | | When ValueError is raised if an integer is larger than the limit, mention sys.set_int_max_str_digits() in the error message. (cherry picked from commit e841ffc915e82e5ea6e3b473205417d63494808d) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.11] gh-96005: Handle WASI ENOTCAPABLE in getpath (GH-96006) (GH-96034) ↵Christian Heimes2022-09-131-0/+5
| | | | | | | | (GH-96038) - On WASI `ENOTCAPABLE` is now mapped to `PermissionError`. - The `errno` modules exposes the new error number. - `getpath.py` now ignores `PermissionError` when it cannot open landmark files `pybuilddir.txt` and `pyenv.cfg`.
* gh-96352: Set AttributeError context in _PyObject_GenericGetAttrWithDict ↵Miss Islington (bot)2022-09-081-0/+2
| | | | | | | (GH-96353) (cherry picked from commit b9634ac776c24bc4d4a57859d884a94cdfe16043) Co-authored-by: philg314 <110174000+philg314@users.noreply.github.com>
* gh-95778: Correctly pre-check for int-to-str conversion (GH-96537)Miss Islington (bot)2022-09-041-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Converting a large enough `int` to a decimal string raises `ValueError` as expected. However, the raise comes _after_ the quadratic-time base-conversion algorithm has run to completion. For effective DOS prevention, we need some kind of check before entering the quadratic-time loop. Oops! =) The quick fix: essentially we catch _most_ values that exceed the threshold up front. Those that slip through will still be on the small side (read: sufficiently fast), and will get caught by the existing check so that the limit remains exact. The justification for the current check. The C code check is: ```c max_str_digits / (3 * PyLong_SHIFT) <= (size_a - 11) / 10 ``` In GitHub markdown math-speak, writing $M$ for `max_str_digits`, $L$ for `PyLong_SHIFT` and $s$ for `size_a`, that check is: $$\left\lfloor\frac{M}{3L}\right\rfloor \le \left\lfloor\frac{s - 11}{10}\right\rfloor$$ From this it follows that $$\frac{M}{3L} < \frac{s-1}{10}$$ hence that $$\frac{L(s-1)}{M} > \frac{10}{3} > \log_2(10).$$ So $$2^{L(s-1)} > 10^M.$$ But our input integer $a$ satisfies $|a| \ge 2^{L(s-1)}$, so $|a|$ is larger than $10^M$. This shows that we don't accidentally capture anything _below_ the intended limit in the check. <!-- gh-issue-number: gh-95778 --> * Issue: gh-95778 <!-- /gh-issue-number --> Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org> (cherry picked from commit b126196838bbaf5f4d35120e0e6bcde435b0b480) Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* [3.11] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96500)Gregory P. Smith2022-09-021-1/+44
| | | | | | | | | | | | | | | | | | Integer to and from text conversions via CPython's bignum `int` type is not safe against denial of service attacks due to malicious input. Very large input strings with hundred thousands of digits can consume several CPU seconds. This PR comes fresh from a pile of work done in our private PSRT security response team repo. This backports https://github.com/python/cpython/pull/96499 aka 511ca9452033ef95bc7d7fc404b8161068226002 Signed-off-by: Christian Heimes [Red Hat] <christian@python.org> Tons-of-polishing-up-by: Gregory P. Smith [Google] <greg@krypto.org> Reviews via the private PSRT repo via many others (see the NEWS entry in the PR). <!-- gh-issue-number: gh-95778 --> * Issue: gh-95778 <!-- /gh-issue-number --> I wrote up [a one pager for the release managers](https://docs.google.com/document/d/1KjuF_aXlzPUxTK4BMgezGJ2Pn7uevfX7g0_mvgHlL7Y/edit#).
* gh-96455: update example in exception_handling_notes.txt to the 3.11RC ↵Miss Islington (bot)2022-09-011-25/+28
| | | | | | | bytecode (GH-96456) (cherry picked from commit a91f25577c71ab8797a4b42f22c43bbaffc2604d) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>