summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* [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>
* GH-96187: Prevent _PyCode_GetExtra to return garbage for negative indexes ↵Miss Islington (bot)2022-08-231-1/+1
| | | | | | | (GH-96188) (cherry picked from commit 16ebae4cd4029205d932751f26c719c6cb8a6e92) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* gh-96046: Initialize ht_cached_keys in PyType_Ready() (GH-96047)Miss Islington (bot)2022-08-221-9/+26
| | | | | (cherry picked from commit 53e6a9a7254bdcd0538580ba7d799cd453e2dca5) Co-authored-by: Christian Heimes <christian@python.org>
* gh-95605: Fix `float(s)` error message when `s` contains only whitespace ↵Miss Islington (bot)2022-08-111-1/+8
| | | | | | | | (GH-95665) (GH-95858) This PR fixes the error message from float(s) in the case where s contains only whitespace. (cherry picked from commit 97e9cfa75a80b54a0630b7371f35e368a12749d1) Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* GH-92678: Document that you shouldn't be doing your own dictionary offset ↵Miss Islington (bot)2022-08-091-1/+5
| | | | | | | calculations. (GH-95598) (GH-95821) Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com> Co-authored-by: Mark Shannon <mark@hotpy.org>
* gh-94936: C getters: co_varnames, co_cellvars, co_freevars (GH-95008)Miss Islington (bot)2022-08-041-0/+18
| | | | | (cherry picked from commit 42b102bbf9a9ae6fae8f6710202fb7afeeac277c) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* Revert "[3.11] GH-92678: Expose managed dict clear and visit functions ↵Mark Shannon2022-08-041-29/+0
| | | | | (GH-95246). (#95256)" (#95647) This reverts commit 7f731943393d57cf26ed5f2353e6e53084cd55fd.
* GH-92678: Fix tp_dictoffset inheritance. (GH-95596) (GH-95604)Mark Shannon2022-08-041-3/+16
| | | | | * Add test for inheriting explicit __dict__ and weakref. * Restore 3.10 behavior for multiple inheritance of C extension classes that store their dictionary at the end of the struct.
* GH-95150: Use position and exception tables for code hashing and equality ↵Miss Islington (bot)2022-08-011-1/+18
| | | | | | | (GH-95509) (cherry picked from commit c7e5bbaee88a71dc6e633e3cd451ed1798436382) Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* gh-95369: add missing decref in error case of exception group's split (GH-95370)Miss Islington (bot)2022-07-281-0/+1
| | | | | (cherry picked from commit bceb197947bbaebb11e01195bdce4f240fdf9332) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* [3.11] gh-95324: Emit a warning if an object doesn't call ↵Miss Islington (bot)2022-07-272-2/+4
| | | | | PyObject_GC_UnTrack during deallocation in debug mode (GH-95325) (#95336) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.11] GH-92678: Expose managed dict clear and visit functions (GH-95246). ↵Pablo Galindo Salgado2022-07-251-0/+29
| | | | | (#95256) Co-authored-by: Mark Shannon <mark@hotpy.org>
* [3.11] GH-94739: Backport GH-94958 to 3.11 (#94965)Mark Shannon2022-07-251-20/+170
|
* gh-95173: Revert commit 51ed2c56a1852cd6b09c85ba81312dc9782772ce (GH-95176)Miss Islington (bot)2022-07-241-64/+13
| | | | | (cherry picked from commit 9007dec606b790c05e158e588b696f3c210c2795) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* GH-94438: Handle extended arguments and conditional pops in mark_stacks ↵Miss Islington (bot)2022-07-221-4/+9
| | | | | | | (GH-95110) (cherry picked from commit e4d3a96a113070fde433834a6c9fb79ebeebad4a) Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
* [3.11] GH-95113: Don't use EXTENDED_ARG_QUICK in unquickened code (GH-95121) ↵Brandt Bucher2022-07-221-1/+1
| | | | | (GH-95143) (cherry picked from commit e402b26b7fb953a2f0c17a0044bb6d6cbd726e54)
* [3.11] GH-95060: Fix PyCode_Addr2Location when addrq < 0 (GH-95094)Miss Islington (bot)2022-07-211-0/+1
| | | | | | (cherry picked from commit a6daaf2a132efbb1965b4502ff8a8cf3b5afed0e) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* GH-90699: fix ref counting of static immortal strings (gh-94850)Miss Islington (bot)2022-07-201-1/+2
| | | | | (cherry picked from commit 1834133e66d95a143c9df5f068b3109927aefd65) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* GH-91153: Handle mutating __index__ methods in bytearray item assignment ↵Miss Islington (bot)2022-07-191-11/+25
| | | | | | | (GH-94891) (cherry picked from commit f36589510b8708fa224d799d5b328deab558aa4e) Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
* gh-94841: Ensure arena_map_get() is inlined in PyObject_Free() (GH-94842)Miss Islington (bot)2022-07-141-1/+1
| | | | | (cherry picked from commit 9b3f7792093c533608f70043aa2a7daf7f903a16) Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
* gh-94607: Fix subclassing generics (GH-94610)Miss Islington (bot)2022-07-091-0/+4
| | | | | | Co-authored-by: Serhiy Storchaka <3659035+serhiy-storchaka@users.noreply.github.com> (cherry picked from commit 6442a9dd212fa18343db21849cf05c0181662c1f) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* [3.11] gh-94438: in frameobject's mark_stacks switch, the PUSH_EXC_INFO and ↵Irit Katriel2022-07-061-8/+10
| | | | | | | POP_EXCEPT cases are no longer reachable (GH-94582) (GH-94595) (cherry picked from commit 50b9a7762f06335277d9962edc8d39498601a4e4) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* [3.11] GH-94262: Don't create frame objects for frames that aren't yet ↵Miss Islington (bot)2022-07-042-8/+13
| | | | | complete. (GH-94371) (#94482) Co-authored-by: Mark Shannon <mark@hotpy.org>