summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* [3.11] GH-94438: Backport GH-94444 (#94486)Mark Shannon2022-07-011-13/+35
| | | * Account for NULLs on evaluation stack when jumping lines.
* [3.11] GH-93516: Backport GH-93769 (GH-94231)Mark Shannon2022-06-281-0/+6
| | | * Store offset of first traceable instruction to avoid having to recompute it all the time when tracing.
* gh-88116: Avoid undefined behavior when decoding varints in code objects ↵Miss Islington (bot)2022-06-281-8/+8
| | | | | | | (GH-94375) (cherry picked from commit c485ec014ce174bb3f5ae948151dc40e0f6d5f7f) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.11] GH-91742: Fix pdb crash after jump (GH-94171) (#94176)Miss Islington (bot)2022-06-231-1/+1
| | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* [3.11] gh-93382: Cache result of `PyCode_GetCode` in codeobject (GH-93383) ↵Ken Jin2022-06-231-0/+8
| | | | | | (#93493) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
* [3.11] GH-93516: Backport GH-93769: Speedup line number checks when tracing ↵Mark Shannon2022-06-221-0/+56
| | | | | (GH-94127) Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* gh-93021: Fix __text_signature__ for __get__ (GH-93023) (GH-94085)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>
* GH-93249: relax overly strict assertion on bounds->ar_start (GH-93961) ↵Miss Islington (bot)2022-06-201-1/+6
| | | | | | | | | (GH-94032) (cherry picked from commit 1603a1029f44f0fdc87c65b02063229962194f84) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* gh-93937, C API: Move PyFrame_GetBack() to Python.h (#93938) (#94000)Victor Stinner2022-06-202-2/+0
| | | | | | | | | | | | | | | | | | Move the follow functions and type from frameobject.h to pyframe.h, so the standard <Python.h> provide frame getter functions: * PyFrame_Check() * PyFrame_GetBack() * PyFrame_GetBuiltins() * PyFrame_GetGenerator() * PyFrame_GetGlobals() * PyFrame_GetLasti() * PyFrame_GetLocals() * PyFrame_Type Remove #include "frameobject.h" from many C files. It's no longer needed. (cherry picked from commit 27b989403356ccdd47545a93aeab8434e9c69f21)
* gh-84461: Silence some compiler warnings on WASM (GH-93978)Miss Islington (bot)2022-06-201-1/+1
| | | | | (cherry picked from commit 774ef28814d0d9d57ec813cb31b0a7af6c476127) Co-authored-by: Christian Heimes <christian@python.org>
* GH-93990: fix refcounting bug in `add_subclass` in `typeobject.c` (GH-93989)Miss Islington (bot)2022-06-191-1/+4
| | | | | (cherry picked from commit 726448ebe15cd78e180c29c9858cb6c10a581524) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-89828: Do not relay the __class__ attribute in GenericAlias (GH-93754)Miss Islington (bot)2022-06-181-0/+1
| | | | | | | | list[int].__class__ returned type, and isinstance(list[int], type) returned True. It caused numerous problems in code that checks isinstance(x, type). (cherry picked from commit f9433fff476aa13af9cb314fcc6962055faa4085) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-92888: Fix memoryview bad `__index__` use after free (GH-92946)Miss Islington (bot)2022-06-181-19/+36
| | | | | | | Co-authored-by: chilaxan <35645806+chilaxan@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <3659035+serhiy-storchaka@users.noreply.github.com> (cherry picked from commit 11190c4ad0d3722b8d263758ac802985131a5462) Co-authored-by: Ken Jin <kenjin@python.org>
* gh-92914: Round the allocated size for lists up to the even number (GH-92915)Miss Islington (bot)2022-06-141-0/+6
| | | | | (cherry picked from commit 8a6af5a34642f5564220eb50d72caada8f17fc78) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-79512: Fixed names and __module__ value of weakref classes (GH-93719)Miss Islington (bot)2022-06-141-3/+3
| | | | | | | | 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>
* [3.11] gh-91162: Support splitting of unpacked arbitrary-length tuple over ↵Miss Islington (bot)2022-06-141-56/+43
| | | | | | | | | | | | TypeVar and TypeVarTuple parameters (alt) (GH-93412) (GH-93746) For example: A[T, *Ts][*tuple[int, ...]] -> A[int, *tuple[int, ...]] A[*Ts, T][*tuple[int, ...]] -> A[*tuple[int, ...], int] (cherry picked from commit 3473817106c23eca7341c931453da0341c367e1d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Fix missing word in sys.float_info docstring (GH-93489) (GH-93495)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>
* gh-93345: Fix a crash in substitution of nested TypeVar after TypeVarTuple ↵Miss Islington (bot)2022-06-011-1/+1
| | | | | | | | (GH-93346) For example: tuple[*Ts, list[T]][int, str, bool] (cherry picked from commit f545fc955aeb701ae4e73b07ff2283f823d857b8) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.11] gh-91162: Fix substitution of unpacked tuples in generic aliases ↵Miss Islington (bot)2022-06-011-13/+108
| | | | | | | | | | | | | (GH-92335) (#92484) * gh-91162: Fix substitution of unpacked tuples in generic aliases (GH-92335) (cherry picked from commit 9d25db9db1617f012d7dba118b5b8f2b9e25e116) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> * Regenerate ABI file Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* [3.11] bpo-40514: Drop EXPERIMENTAL_ISOLATED_SUBINTERPRETERS (gh-93185) ↵Eric Snow2022-05-282-40/+3
| | | | | | | | | | | | | (GH-93306) (cherry picked from commit caa279d6fd5f151e57f891cd4f6ba51b532501c6) This was added for bpo-40514 (gh-84694) to test out a per-interpreter GIL. However, it has since proven unnecessary to keep the experiment in the repo. (It can be done as a branch in a fork like normal.) So here we are removing: * the configure option * the macro * the code enabled by the macro Automerge-Triggered-By: GH:ericsnowcurrently
* GH-92804: Fix memory leak in memoryview iterator (gh-92805)Miss Islington (bot)2022-05-142-3/+5
| | | | | (cherry picked from commit d923fdf54bc97baece879179ba4971f632b9722b) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* Issues/88027: A potential double free in list_sort_impl (#92367)Tim Peters2022-05-061-1/+3
| | | merge_freemem(): set keys to NULL do it's harmless to call this again.
* gh-92112: Fix crash triggered by an evil custom `mro()` (#92113)Alexey Izbyshev2022-05-061-9/+11
|
* gh-87390: Fix starred tuple equality and pickling (GH-92337)Serhiy Storchaka2022-05-051-0/+26
|