summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* [3.10] gh-101892: Fix `SystemError` when a callable iterator call exhausts ↵Oleg Iarygin2023-03-041-2/+2
| | | | | | | | | | the iterator (GH-101896) (#102422) gh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (#101896) Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net> (cherry picked from commit 705487c6557c3d8866622b4d32528bf7fc2e4204) Co-authored-by: Raj <51259329+workingpayload@users.noreply.github.com>
* 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.10] gh-101765: Fix refcount issues in list and unicode pickling ↵Jelle Zijlstra2023-02-262-1/+11
| | | | | (GH-102265) (#102269) (cherry picked from commit d71edbd1b7437706519a9786211597d95934331a)
* [3.10] gh-101765: Fix SystemError / segmentation fault in iter `__reduce__` ↵Ionite2023-02-256-24/+60
| | | | | | when internal access of `builtins.__dict__` exhausts the iterator (GH-101769) (#102229) (cherry picked from commit 54dfa14c5a94b893b67a4d9e9e403ff538ce9023)
* 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.10] GH-100942: Fix incorrect cast in property_copy(). (GH-100965). (#101009)Nikita Sobolev2023-01-151-3/+4
| | | | | (cherry picked from commit 94fc7706b7bc3d57cdd6d15bf8e8c4499ae53a69) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
* gh-99845: _PyObject_DictPointer(): fix dictoffset cast (GH-99922)Miss Islington (bot)2022-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. (cherry picked from commit 9707bf228e008485a3fbb63aa7ee28cf88014f91) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.10] gh-98852: Fix subscription of types.GenericAlias instances (GH-98920) ↵Serhiy Storchaka2022-11-011-0/+8
| | | | | | | (GH-98969) Fix subscription of types.GenericAlias instances containing bare generic types: for example tuple[A, T][int], where A is a generic type, and T is a type variable.
* 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>
* [3.10] gh-97943: PyFunction_GetAnnotations should return a borrowed ↵Miss Islington (bot)2022-10-071-2/+5
| | | | | | | | reference. (GH-97949) (GH-97989) gh-97943: PyFunction_GetAnnotations should return a borrowed reference. (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>
* 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>
* 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>
* [3.10] gh-95778: Correctly pre-check for int-to-str conversion (GH-96537) ↵Gregory P. Smith2022-09-041-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#96563) 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.10] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96501)Gregory P. Smith2022-09-021-1/+45
| | | | | | | | | | | | | | | | | 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#).
* [3.10] GH-96187: Prevent _PyCode_GetExtra to return garbage for negative ↵Pablo Galindo Salgado2022-08-231-1/+1
| | | | | | | indexes (GH-96188). (#96210) (cherry picked from commit 16ebae4cd4029205d932751f26c719c6cb8a6e92) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] GH--93592: Fix frame chain when throwing exceptions into coroutines ↵Kristján Valur Jónsson2022-08-231-4/+9
| | | | (GH-95207)
* gh-95605: Fix `float(s)` error message when `s` contains only whitespace ↵Miss Islington (bot)2022-08-101-1/+8
| | | | | | | | (GH-95665) (GH-95859) 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-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>
* [3.10] gh-94841: Ensure arena_map_get() is inlined in PyObject_Free() (GH-94842)Neil Schemenauer2022-07-151-1/+11
| | | | | Need to define ALWAYS_INLINE macro for 3.10. Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
* gh-92888: Fix memoryview bad `__index__` use after free (GH-92946) (GH-93950)Ken Jin2022-06-231-19/+36
| | | | | | (cherry picked from commit 11190c4ad0d3722b8d263758ac802985131a5462) Co-authored-by: chilaxan <35645806+chilaxan@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <3659035+serhiy-storchaka@users.noreply.github.com>
* gh-93021: Fix __text_signature__ for __get__ (GH-93023) (GH-94086)Miss Islington (bot)2022-06-211-2/+2
| | | | | | | | Because of the way wrap_descr_get is written, the second argument to __get__ methods implemented through the wrapper is always optional. (cherry picked from commit 4e08fbcfdfa57ea94091aabdd09413708e3fb2bf) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* [3.10] gh-79512: Fixed names and __module__ value of weakref classes ↵Serhiy Storchaka2022-06-211-3/+3
| | | | | | | | | | (GH-93719) (GH-94071) Classes ReferenceType, ProxyType and CallableProxyType have now correct atrtributes __module__, __name__ and __qualname__. It makes them (types, not instances) pickleable. (cherry picked from commit 8352e322e87ba39c71e578b65ad8ae156ca3e0c7) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989) ↵Kumar Aditya2022-06-191-1/+4
| | | | | (GH-93999) (cherry picked from commit 726448ebe15cd78e180c29c9858cb6c10a581524)
* gh-92914: Round the allocated size for lists up to the even number ↵Miss Islington (bot)2022-06-071-0/+6
| | | | | | | (GH-92915) (GH-92942) (cherry picked from commit 8a6af5a34642f5564220eb50d72caada8f17fc78) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Fix missing word in sys.float_info docstring (GH-93489) (GH-93496)Miss Islington (bot)2022-06-041-1/+1
| | | | | | | (cherry picked from commit e12f34b6d8200508bd50cdc9c6c5637732ff56e7) Co-authored-by: Mark Dickinson <dickinsm@gmail.com> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-39829: Fix `__len__()` is called twice in list() constructor (GH-31816)Miss Islington (bot)2022-05-181-17/+12
| | | | | | | (cherry picked from commit 2153daf0a02a598ed5df93f2f224c1ab2a2cca0d) This patch fixes gh-87740 too. Co-authored-by: Crowthebird <78076854+thatbirdguythatuknownot@users.noreply.github.com>
* [3.10] gh-92311: Let frame_setlineno jump over listcomps (GH-92717)Dennis Sweeney2022-05-121-1/+4
|
* [3.10] gh-92112: Fix crash triggered by an evil custom `mro()` (GH-92113) ↵Jelle Zijlstra2022-05-071-9/+11
| | | | | | | (#92370) (cherry picked from commit 85354ed78c0edb6d81a2bd53cabc85e547b8b26e) Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
* Issues/88027: A potential double free in list_sort_impl (GH-92367)Miss Islington (bot)2022-05-061-1/+3
| | | | | | merge_freemem(): set keys to NULL do it's harmless to call this again. (cherry picked from commit 9652900969df77b1ac245595419431df19296af9) Co-authored-by: Tim Peters <tim.peters@gmail.com>
* [3.10] bpo-43504: Remove effbot urls (GH-26308) (#92161)Thaddeus14992022-05-021-1/+2
| | | | | | * [3.10] Remove effbot urls (GH-26308). (cherry picked from commit e9f66aedf44ccc3be27975cfb070a44ce6a6bd13) Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
* bpo-36819: Fix crashes in built-in encoders with weird error handlers (GH-28593)Miss Islington (bot)2022-05-022-23/+52
| | | | | | | | | If the error handler returns position less or equal than the starting position of non-encodable characters, most of built-in encoders didn't properly re-size the output buffer. This led to out-of-bounds writes, and segfaults. (cherry picked from commit 18b07d773e09a2719e69aeaa925d5abb7ba0c068) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.10] gh-91118: Fix docstrings that do not honor --without-doc-strings ↵Oleg Iarygin2022-04-193-7/+9
| | | | | | | | | (GH-31769) (#91662) Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit a573cb2fec664c645ab744658d7e941d72e1a398) Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
* gh-91421: Use constant value check during runtime (GH-91422) (GH-91492)Miss Islington (bot)2022-04-141-1/+1
| | | | | | | | | | | | | | | | The left-hand side expression of the if-check can be converted to a constant by the compiler, but the addition on the right-hand side is performed during runtime. Move the addition from the right-hand side to the left-hand side by turning it into a subtraction there. Since the values are known to be large enough to not turn negative, this is a safe operation. Prevents a very unlikely integer overflow on 32 bit systems. Fixes GH-91421. (cherry picked from commit 0859368335d470b9ff33fc53ed9a85ec2654b278) Co-authored-by: Tobias Stoeckmann <stoeckmann@users.noreply.github.com>
* Fix bad grammar and import docstring for split/rsplit (GH-32381) (GH-32416)Miss Islington (bot)2022-04-082-22/+37
|
* [3.10] bpo-47182: Fix crash by named unicode characters after interpreter ↵Christian Heimes2022-04-011-0/+3
| | | | | reinitialization (GH-32212) (GH-32216) Co-authored-by: Christian Heimes <christian@python.org>
* bpo-14911: Corrected generator.throw() documentation (GH-32207)Miss Islington (bot)2022-03-311-4/+10
| | | | | | Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com> (cherry picked from commit 8be7c2bc5ad5e295f0f855bb31db412eef2c7c92) Co-authored-by: Dave Goncalves <davegoncalves@gmail.com>
* bpo-46775: OSError should call winerror_to_errno unconditionally on Windows ↵Miss Islington (bot)2022-03-311-8/+1
| | | | | | | (GH-32179) (cherry picked from commit d0c67ea0645b7ad37b867c167882a346a24de641) Co-authored-by: Dong-hee Na <donghee.na@python.org>
* bpo-43721: Fix docstrings for property.getter/setter/deleter (GH-31046)Miss Islington (bot)2022-03-141-3/+3
| | | | | (cherry picked from commit e3d348a5252549708fd19338b675a2c23b60d677) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* [3.10] bpo-46940: Don't override existing AttributeError suggestion ↵Pablo Galindo Salgado2022-03-071-12/+22
| | | | | | | | | | | | | | | information (GH-31710) (GH-31724) When an exception is created in a nested call to PyObject_GetAttr, any external calls will override the context information of the AttributeError that we have already placed in the most internal call. This will cause the suggestions we create to nor work properly as the attribute name and object that we will be using are the incorrect ones. To avoid this, we need to check first if these attributes are already set and bail out if that's the case.. (cherry picked from commit 3b3be05a164da43f201e35b6dafbc840993a4d18) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-46852: Rename float.__set_format__() to float.__setformat__() (GH-31558) ↵Victor Stinner2022-02-252-17/+17
| | | | | | | | | | | | | | | (GH-31578) Rename the private undocumented float.__set_format__() method to float.__setformat__() to fix a typo introduced in Python 3.7. The method is only used by test_float. The change enables again test_float tests on the float format which were previously skipped because of the typo. The typo was introduced in Python 3.7 by bpo-20185 in commit b5c51d3dd95bbfde533655fb86ac0f96f771ba7b. (cherry picked from commit 7d03c8be5af2f1559dbc35b775b3116dfd63cfb6)
* [3.10] bpo-46732: fix __bool__ docstring (GH-31301) (GH-31473)Miss Islington (bot)2022-02-211-1/+1
| | | | | | (cherry picked from commit 0a222db2bca63070f429c0e613707da1bdfaf0e0) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-46615: Don't crash when set operations mutate the sets (GH-31120)Miss Islington (bot)2022-02-111-8/+39
| | | | | | Ensure strong references are acquired whenever using `set_next()`. Added randomized test cases for `__eq__` methods that sometimes mutate sets when called. (cherry picked from commit 4a66615ba736f84eadf9456bfd5d32a94cccf117) Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
* [3.10] bpo-46433: _PyType_GetModuleByDef: handle static types in MRO ↵Petr Viktorin2022-02-111-9/+7
| | | | | | | (GH-30696) (GH-31262) (cherry picked from commit 0ef08530124c5ca13a9394f4ac18bee8e6c66409)
* bpo-46417: Fix race condition on setting type __bases__ (GH-30788) (GH-30789)Miss Islington (bot)2022-01-221-11/+16
| | | | | | | | | | | | Fix a race condition on setting a type __bases__ attribute: the internal function add_subclass() now gets the PyTypeObject.tp_subclasses member after calling PyWeakref_NewRef() which can trigger a garbage collection which can indirectly modify PyTypeObject.tp_subclasses. (cherry picked from commit f1c6ae3270913e095d24ae13ecf96f5a32c8c503) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
* docs: correct outdated MappingProxyType docstrings (GH-30281)Miss Islington (bot)2022-01-191-3/+3
| | | | | | | | The docstrings for MappingProxyType's keys(), values(), and items() methods were never updated to reflect the changes that Python 3 brought to these APIs, namely returning views rather than lists. (cherry picked from commit 2d10fa9bc4cf83c5e5dd73decc9a138d6d247374) Co-authored-by: Joshua Bronson <jabronson@gmail.com>
* [3.10] bpo-46006: Revert "bpo-40521: Per-interpreter interned strings ↵Victor Stinner2022-01-062-17/+68
| | | | | | | | | | | | | | | | | (GH-20085)" (GH-30422) (GH-30425) This reverts commit ea251806b8dffff11b30d2182af1e589caf88acf. Keep "assert(interned == NULL);" in _PyUnicode_Fini(), but only for the main interpreter. Keep _PyUnicode_ClearInterned() changes avoiding the creation of a temporary Python list object. Leave the PyInterpreterState structure unchanged to keep the ABI backward compatibility with Python 3.10.0: rename the "interned" member to "unused_interned". (cherry picked from commit 35d6540c904ef07b8602ff014e520603f84b5886)
* bpo-46236: Fix PyFunction_GetAnnotations() returned tuple. (GH-30409)Miss Islington (bot)2022-01-051-22/+33
| | | | | | Automerge-Triggered-By: GH:pablogsal (cherry picked from commit 46e4c257e7c26c813620232135781e6c53fe8d4d) Co-authored-by: Inada Naoki <songofacandy@gmail.com>