summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* [3.9] gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data ↵Serhiy Storchaka2023-08-221-0/+3
| | | | | | | (GH-99613) (GH-107224) (#107231) Previously *consumed was not set in this case. (cherry picked from commit f08e52ccb027f6f703302b8c1a82db9fd3934270). (cherry picked from commit b8b3e6afc0a48c3cbb7c36d2f73e332edcd6058c)
* [3.9] gh-95778: Mention sys.set_int_max_str_digits() in error message ↵Victor Stinner2022-10-041-2/+2
| | | | | | | | | | (#96874) (#96877) 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: Ned Deily <nad@python.org>
* [3.9] gh-97616: list_resize() checks for integer overflow (GH-97617) (GH-97627)Miss Islington (bot)2022-10-041-2/+8
| | | | | | | | | | | | | gh-97616: list_resize() checks for integer overflow (GH-97617) 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>
* [3.9] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96502)Gregory P. Smith2022-09-051-1/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Correctly pre-check for int-to-str conversion (#96537) 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> Co-authored-by: Christian Heimes <christian@python.org> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* [3.9] gh-92112: Fix crash triggered by an evil custom `mro()` (GH-92113) ↵Jelle Zijlstra2022-05-161-9/+11
| | | | | | | (GH-92372) (cherry picked from commit 85354ed78c0edb6d81a2bd53cabc85e547b8b26e) Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
* [3.9] gh-92311: Let frame_setlineno jump over listcomps (#92740)Dennis Sweeney2022-05-121-1/+4
|
* [3.9] Remove effbot urls (GH-26308). (#92162)Thaddeus14992022-05-021-1/+2
| | | | | (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.9] gh-91118: Fix docstrings that do not honor --without-doc-strings ↵Oleg Iarygin2022-04-192-5/+7
| | | | | | | | (GH-31769) (#91664) Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit a573cb2fec664c645ab744658d7e941d72e1a398)
* gh-91421: Use constant value check during runtime (GH-91422) (GH-91493)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>
* 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>
* bpo-46852: Rename float.__set_format__() to float.__setformat__() (GH-31558) ↵Victor Stinner2022-02-252-17/+17
| | | | | | | | | | | | | | | (GH-31581) 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.9] bpo-46732: fix __bool__ docstring (GH-31301) (GH-31474)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) (GH-31312)Dennis Sweeney2022-02-131-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)
* bpo-46417: Fix race condition on setting type __bases__ (GH-30788) (GH-30790)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>
* bpo-46085: Fix iterator cache mechanism of OrderedDict. (GH-30290)Miss Islington (bot)2021-12-301-3/+5
| | | | | (cherry picked from commit fb44d0589615590b1e7895ba78a038e96b15a219) Co-authored-by: Dong-hee Na <donghee.na@python.org>
* bpo-45392: Update the docstring of the 'type' built-in (GH-29439) (GH-29453)Miss Islington (bot)2021-11-061-3/+1
| | | | | (cherry picked from commit 91275207296c39e495fe118019a757c4ddefede8) Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
* bpo-30570: Use Py_EnterRecursiveCall() in issubclass() (GH-29048) (GH-29178)Miss Islington (bot)2021-11-041-6/+14
| | | | | | | | * Use Py_EnterRecursiveCall() in issubclass() Reviewed-by: Gregory P. Smith <greg@krypto.org> [Google] (cherry picked from commit 423fa1c1817abfa8c3d1bc308ddbbd8f28b69d68) Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
* bpo-45467: Fix IncrementalDecoder and StreamReader in the ↵Serhiy Storchaka2021-10-141-20/+44
| | | | | | | | | | "raw-unicode-escape" codec (GH-28944) (GH-28953) They support now splitting escape sequences between input chunks. Add the third parameter "final" in codecs.raw_unicode_escape_decode(). It is True by default to match the former behavior. (cherry picked from commit 39aa98346d5dd8ac591a7cafb467af21c53f1e5d)
* [3.9] bpo-45461: Fix IncrementalDecoder and StreamReader in the ↵Serhiy Storchaka2021-10-141-12/+37
| | | | | | | | | | | | "unicode-escape" codec (GH-28939) (GH-28945) They support now splitting escape sequences between input chunks. Add the third parameter "final" in codecs.unicode_escape_decode(). It is True by default to match the former behavior. (cherry picked from commit c96d1546b11b4c282a7e21737cb1f5d16349656d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.9] Fix typos in the Objects directory (GH-28766) (GH-28795)Christian Clauss2021-10-076-7/+7
| | | | | (cherry picked from commit 5f401f10400123afa9171548c432ea3fc37c0736) Automerge-Triggered-By: GH:JulienPalard
* [3.9] bpo-45385: Fix reference leak from descr_check (GH-28719) (GH-28780)Dong-hee Na2021-10-071-39/+41
| | | | | (cherry picked from commit e6ff4eba6da9b64aed235ba8d730b5645f71955c) Co-authored-by: Dong-hee Na <donghee.na@python.org>
* [3.9] Remove trailing spaces (GH-28710)Serhiy Storchaka2021-10-031-1/+1
|
* [3.9] [codemod] Fix non-matching bracket pairs (GH-28473) (GH-28512)Łukasz Langa2021-09-221-1/+1
| | | | | | | | Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>. (cherry picked from commit 8f943ca25732d548cf9f0b0393ba8d582fb93e29) Co-authored-by: Mohamad Mansour <66031317+mohamadmansourX@users.noreply.github.com>
* bpo-45167: Fix deepcopying of GenericAlias (GH-28324) (GH-28368)Miss Islington (bot)2021-09-151-0/+2
| | | | | (cherry picked from commit 5dce51a8875d9639786741e962b3cb208596b096) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-45030: Fix integer overflow in __reduce__ of the range iterator (GH-28000)Miss Islington (bot)2021-09-041-16/+18
| | | | | | | It happened with fast range iterator when the calculated stop = start + step * len was out of the C long range. (cherry picked from commit 936f6a16b9ef85bd56b18a247b962801e954c30e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.9] bpo-45083: Include the exception class qualname when formatting an ↵Miss Islington (bot)2021-09-031-0/+8
| | | | | | | | | | | exception (GH-28119) (GH-28135) * bpo-45083: Include the exception class qualname when formatting an exception (GH-28119) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no> (cherry picked from commit b4b6342848ec0459182a992151099252434cc619) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-45018: Fix rangeiter_reduce in rangeobject.c (GH-27938) (GH-27991)Miss Islington (bot)2021-08-271-1/+1
| | | | | | Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 94a3d2a6329ab7941e93ad2f5bcbb8af2b8b80d2) Co-authored-by: chilaxan <chilaxan@gmail.com>
* bpo-44954: Fix wrong result in float.fromhex corner case (GH-27834) (GH-27855)Miss Islington (bot)2021-08-201-2/+2
| | | | | (cherry picked from commit 60b93d9e4922eeae25052bc15909d1f4152babde) Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
* bpo-44698: Restore complex pow behaviour for small integral exponents ↵Miss Islington (bot)2021-08-171-21/+7
| | | | | | | (GH-27772) (GH-27797) (cherry picked from commit 4b9a2dcf19e5d13c3bc2afea2de1f65cd994c699) Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
* bpo-33930: Fix segfault with deep recursion when cleaning method objects ↵Miss Islington (bot)2021-08-111-1/+5
| | | | | | | (GH-27678) (GH-27720) (cherry picked from commit bfc2d5a5c4550ab3a2fadeb9459b4bd948ff61a2) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-44872: use new trashcan macros in framobject.c (GH-27683) (GH-27691)Irit Katriel2021-08-101-2/+2
|
* bpo-44707: Fix an undefined behavior of the null pointer arithmetic ↵Miss Islington (bot)2021-07-291-2/+9
| | | | | | | (GH-27292) (GH-27443) (cherry picked from commit e5c8ddb1714fb51ab1defa24352c98e0f01205dc) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44657: Fix instancemethod_call to use PyInstanceMethod_GET_FUNCTION ↵Miss Islington (bot)2021-07-281-1/+1
| | | | | | | (GH-27202) (cherry picked from commit ddf8ae31a0f371eff2db14c7f7a45976b86d56ea) Co-authored-by: Dong-hee Na <donghee.na@python.org>
* bpo-44698: Fix undefined behaviour in complex exponentiation. (GH-27278) ↵Miss Islington (bot)2021-07-261-8/+15
| | | | | | | (GH-27367) (cherry picked from commit 1d582bbc969e05896addf97844ddf17ce9830e5e) Co-authored-by: T. Wouters <thomas@python.org>
* bpo-44720: Don't crash when calling weakref.proxy(not_an_iterator).__next__ ↵Miss Islington (bot)2021-07-241-0/+6
| | | | | | | (GH-27316) (#27325) (cherry picked from commit 5370f0a82aaa4ba617070d5c71d2b18236096ac0) Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
* bpo-44184: Fix subtype_dealloc() for freed type (GH-26274)Miss Islington (bot)2021-07-151-2/+9
| | | | | | | | | | | | Fix a crash at Python exit when a deallocator function removes the last strong reference to a heap type. Don't read type memory after calling basedealloc() since basedealloc() can deallocate the type and free its memory. _PyMem_IsPtrFreed() argument is now constant. (cherry picked from commit 615069eb08494d089bf24e43547fbc482ed699b8) Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-44184: Apply GH-26274 to the non-GC-type branch of subtype_dealloc ↵Miss Islington (bot)2021-07-151-3/+11
| | | | | | | | | | | (GH-27165) (GH-27175) The non-GC-type branch of subtype_dealloc is using the type of an object after freeing in the same unsafe way as GH-26274 fixes. (I believe the old news entry covers this change well enough.) https://bugs.python.org/issue44184 (cherry picked from commit 074e7659f208051b6b973f7fdb654dd22b93aaa2) Co-authored-by: T. Wouters <thomas@python.org>
* [3.9] bpo-44562: Remove invalid PyObject_GC_Del from error path of ↵Ken Jin2021-07-051-4/+4
| | | | types.GenericAlias … (GH-27016) (GH-27028)
* Revert "bpo-44562: Remove invalid PyObject_GC_Del from error path of ↵Pablo Galindo2021-07-041-3/+3
| | | | | types.GenericAlias … (GH-27016) (GH-27018)" (GH-27022) This reverts commit 4684a34c8d2a2ffac7b779edb4ba57f043783478.
* bpo-44562: Remove invalid PyObject_GC_Del from error path of ↵Miss Islington (bot)2021-07-041-3/+3
| | | | | | | | | types.GenericAlias … (GH-27016) (GH-27018) (cherry picked from commit d33943a6c368c2184e238019c63ac7a267da5594) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-44523: Remove the pass-through for hash() in weakref proxy objects ↵Miss Islington (bot)2021-06-291-16/+2
| | | | | | | (GH-26950) (GH-26960) (cherry picked from commit e2fea101fd5517f33371b04432842b971021c3bf) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* Fix a potential reference-counting bug in long_pow (GH-26690) (#26702)Miss Islington (bot)2021-06-131-0/+1
| | | | | | | (cherry picked from commit 59242431991794064824cf2ab70886367613f29e) Co-authored-by: Mark Dickinson <mdickinson@enthought.com> Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
* [3.9] bpo-43667: Fix broken Unicode encoding in non-UTF locales on Solaris ↵Jakub Kulík2021-05-211-0/+40
| | | | | | | (GH-25096) (GH-25847) (cherry picked from commit 9032cf5cb1e33c0349089cfb0f6bf11ed3c30e86) Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
* bpo-44114: Fix dictkeys_reversed and dictvalues_reversed function signatures ↵Miss Islington (bot)2021-05-161-4/+4
| | | | | | | | | | | | (GH-26062) (GH-26093) These are passed and called as PyCFunction, however they are defined here without the (ignored) args parameter. This works fine in some C compilers, but fails in webassembly or anything else that has strict function pointer call type checking. (cherry picked from commit ab383eb6f03896b0ef6634ee3d776344fcb9e5b8) Co-authored-by: Joe Marshall <joe.marshall@nottingham.ac.uk> Co-authored-by: Joe Marshall <joe.marshall@nottingham.ac.uk>
* bpo-44114: Remove redundant cast. (GH-26098)Miss Islington (bot)2021-05-131-2/+2
| | | | | (cherry picked from commit e0c614e5fd017ca43cab55a9f8490133750c704f) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* [3.9] bpo-42083: Allow NULL doc in PyStructSequence_NewType (#25896)Petr Viktorin2021-05-041-6/+11
| | | | | (cherry picked from commit 2f5baa17504feb9a7613bac32fdceed4894434de) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>