summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-128078: Use `PyErr_SetRaisedException` in ↵Miss Islington (bot)2025-02-031-22/+10
| | | | | | | | | `_PyGen_SetStopIterationValue` (GH-128287) (#128789) gh-128078: Use `PyErr_SetRaisedException` in `_PyGen_SetStopIterationValue` (GH-128287) (cherry picked from commit 402b91da87052878b4e7e8946ba91bdf4ee4bebe) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* [3.13] gh-128078: Clear exception in `anext` before calling ↵Miss Islington (bot)2025-01-132-0/+3
| | | | | | | | | `_PyGen_SetStopIterationValue` (GH-128780) (#128785) gh-128078: Clear exception in `anext` before calling `_PyGen_SetStopIterationValue` (GH-128780) (cherry picked from commit 76ffaef729c91bb79da6df2ade48f3ec51118300) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* [3.13] gh-128759: fix data race in `type_modified_unlocked` (GH-128764) ↵Miss Islington (bot)2025-01-131-0/+6
| | | | | | | | (#128769) * gh-128759: fix data race in `type_modified_unlocked` (GH-128764) (cherry picked from commit 6e1e78054060ad326f26dd8dbf12adfedbb52883) Co-authored-by: sobolevn <mail@sobolevn.me>
* [3.13] gh-126862: Use `Py_ssize_t` instead of `int` when processing the ↵Miss Islington (bot)2025-01-101-4/+4
| | | | | | | | number of super-classes (GH-127523) (#128699) gh-126862: Use `Py_ssize_t` instead of `int` when processing the number of super-classes (GH-127523) (cherry picked from commit 2fcdc8488c32d18f4567f797094068a994777f16) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* [3.13] gh-127903: Fix a crash on debug builds when calling ↵Miss Islington (bot)2025-01-031-3/+6
| | | | | | | | `Objects/unicodeobject::_copy_characters` (GH-127876) (#128458) gh-127903: Fix a crash on debug builds when calling `Objects/unicodeobject::_copy_characters`` (GH-127876) (cherry picked from commit 46cb6340d7bad955edfc0a20f6a52dabc03b0932) Co-authored-by: Alexander Shadchin <shadchin@yandex-team.com>
* [3.13] gh-128013: fix data race in PyUnicode_AsUTF8AndSize on free-threading ↵Kumar Aditya2025-01-021-59/+107
| | | | (#128021) (#128417)
* [3.13] Clean up redundant ifdef in list getitem (GH-128257) (#128276)Miss Islington (bot)2024-12-261-4/+0
| | | | | | | | Clean up redundant ifdef in list getitem (GH-128257) It's already inside a `Py_GIL_DISABLED` block so the `#else` clause is always unused. (cherry picked from commit 42f7a00ae8b6b3fa09115e24b9512216c6c8978e) Co-authored-by: da-woods <dw-git@d-woods.co.uk>
* [3.13] gh-128198: Add missing error checks for usages of PyIter_Next() ↵Serhiy Storchaka2024-12-262-0/+8
| | | | | | | (GH-128199) (GH-128272) (cherry picked from commit 5c814c83cdd3dc42bd9682106ffb7ade7ce6b5b3) Co-authored-by: Yan Yanchii <yyanchiy@gmail.com>
* [3.13] gh-126076: Account for relocated objects in tracemalloc (GH-126077) ↵Pablo Galindo Salgado2024-12-114-15/+5
| | | | | (#127823) (cherry picked from commit 30aeb00d367d0cc9e5a7603371636cddea09f1c0)
* [3.13] gh-127563: use `dk_log2_index_bytes=3` in empty dicts (GH-127568) ↵Miss Islington (bot)2024-12-111-1/+4
| | | | | | | | (GH-127798) This fixes a UBSan failure (unaligned zero-size memcpy) in `dictobject.c`. (cherry picked from commit 9af96f440618304e7cc609c246e1f8c8b2d7a119) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* [3.13] gh-127582: Make object resurrection thread-safe for free threading. ↵Sam Gross2024-12-054-20/+41
| | | | | | | | | | | | | | | (GH-127612) (GH-127659) Objects may be temporarily "resurrected" in destructors when calling finalizers or watcher callbacks. We previously undid the resurrection by decrementing the reference count using `Py_SET_REFCNT`. This was not thread-safe because other threads might be accessing the object (modifying its reference count) if it was exposed by the finalizer, watcher callback, or temporarily accessed by a racy dictionary or list access. This adds internal-only thread-safe functions for temporary object resurrection during destructors. (cherry picked from commit f4f530804b9d8f089eba0f157ec2144c03b13651)
* [3.13] gh-127536: Add missing locks in listobject.c (GH-127580) (GH-127613)Sam Gross2024-12-041-10/+40
| | | | | We were missing locks around some list operations in the free threading build. (cherry picked from commit e51da64ac3bc6cd45339864db32d05115af39ead)
* [3.13] gh-127521: Mark list as "shared" before resizing if necessary ↵Miss Islington (bot)2024-12-031-0/+20
| | | | | | | | | | | | | | (GH-127524) (GH-127533) In the free threading build, if a non-owning thread resizes a list, it must use QSBR to free the old list array because there may be a concurrent access (without a lock) from the owning thread. To match the pattern in dictobject.c, we just mark the list as "shared" before resizing if it's from a non-owning thread and not already marked as shared. (cherry picked from commit c7dec02de2ed4baf3cd22ad094350265b52c18af) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-113841: fix possible undefined division by 0 in _Py_c_pow() ↵Miss Islington (bot)2024-12-021-1/+1
| | | | | | | | | | | (GH-127211) (#127216) Note, that transformed expression is not an equivalent for original one (1/exp(-x) != exp(x) in general for floating-point numbers). Though, the difference seems to be ~1ULP for good libm implementations. It's more interesting why division was used from beginning. Closest algorithm I've found (no error checks, of course;)) - it's Algorithm 190 from ACM: https://dl.acm.org/doi/10.1145/366663.366679. It uses subtraction in the exponent. (cherry picked from commit f7bb658124aba74be4c13f498bf46cfded710ef9) Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
* [3.13] Fix Unicode encode_wstr_utf8() (#127420) (#127505)Bénédikt Tran2024-12-021-1/+1
| | | | | | | Fix Unicode encode_wstr_utf8() (#127420) Raise RuntimeError instead of RuntimeWarning. Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-127316: fix incorrect assertion in setting `__class__` in ↵Miss Islington (bot)2024-11-291-1/+1
| | | | | | | | free-threading (GH-127399) (#127422) gh-127316: fix incorrect assertion in setting `__class__` in free-threading (GH-127399) (cherry picked from commit 45c5cba318a19dda3ee6f9fc84781cc7a2fbde80) Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* [3.13] gh-127020: Make `PyCode_GetCode` thread-safe for free threading ↵Miss Islington (bot)2024-11-211-27/+51
| | | | | | | | | (GH-127043) (GH-127107) Some fields in PyCodeObject are lazily initialized. Use atomics and critical sections to make their initializations and accesses thread-safe. (cherry picked from commit 3926842117feffe5d2c9727e1899bea5ae2adb28) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-126980: Fix `bytearray.__buffer__` crash on `PyBUF_{READ,WRITE}` ↵sobolevn2024-11-191-4/+4
| | | | | | | (GH-126981) (#127023) (cherry picked from commit 3932e1db5353bbcf3e3c1133cc9d2cde654cb645) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-126594: Fix typeobject.c wrap_buffer() cast (GH-126754) (#127004)Miss Islington (bot)2024-11-191-3/+3
| | | | | | | | | | gh-126594: Fix typeobject.c wrap_buffer() cast (GH-126754) Reject flags smaller than INT_MIN. (cherry picked from commit 84f07c3a4cbcfe488ccfb4030571be0bc4de7e45) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* [3.13] gh-126341: add release check to `__iter__` method of `memoryview` ↵Miss Islington (bot)2024-11-131-0/+1
| | | | | | | | | | | | (GH-126759) (#126778) gh-126341: add release check to `__iter__` method of `memoryview` (GH-126759) (cherry picked from commit a12690ef49e8fc8a3af4c5f1757eb3caffb35e03) Co-authored-by: Ritvik Pasham <ritvikpasham@gmail.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: sobolevn <mail@sobolevn.me>
* [3.13] gh-116510: Fix a Crash Due to Shared Immortal Interned Strings ↵Miss Islington (bot)2024-11-122-18/+86
| | | | | | | | | | | | | | | | | | | | | | | | | (gh-124865) (gh-125709) (GH-125204) * gh-116510: Fix a Crash Due to Shared Immortal Interned Strings (gh-124865) Fix a crash caused by immortal interned strings being shared between sub-interpreters that use basic single-phase init. In that case, the string can be used by an interpreter that outlives the interpreter that created and interned it. For interpreters that share obmalloc state, also share the interned dict with the main interpreter. This is an un-revert of gh-124646 that then addresses the Py_TRACE_REFS failures identified by gh-124785. (cherry picked from commit f2cb39947093feda3ff85b8dc820922cc5e5f954) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com> * [3.13] gh-125286: Share the Main Refchain With Legacy Interpreters (gh-125709) They used to be shared, before 3.12. Returning to sharing them resolves a failure on Py_TRACE_REFS builds. --------- Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* [3.13] gh-126303: Fix pickling and copying of os.sched_param objects ↵Miss Islington (bot)2024-11-051-0/+6
| | | | | | | (GH-126336) (GH-126423) (cherry picked from commit d3840503b0f590ee574fbdf3c96626ff8b3c45f6) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] gh-116938: Fix `dict.update` docstring and remove erraneous full stop ↵Miss Islington (bot)2024-10-291-2/+2
| | | | | | | | | from `dict` documentation (GH-125421) (#126150) gh-116938: Fix `dict.update` docstring and remove erraneous full stop from `dict` documentation (GH-125421) (cherry picked from commit 5527c4051c0b58218ce69044f92b45f1d66ed43f) Co-authored-by: Prometheus3375 <35541026+Prometheus3375@users.noreply.github.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
* [3.13] gh-125608: Trigger dictionary watchers when inline values change ↵Miss Islington (bot)2024-10-251-6/+15
| | | | | | | | | | (GH-125611) (GH-125982) Dictionary watchers on an object's attributes dictionary (`object.__dict__`) were not triggered when the managed dictionary used the object's inline values. (cherry picked from commit 5989eb74463c26780632f17f221d6bf4c9372a01) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-123930: Better error for "from imports" when script shadows module ↵Shantanu2024-10-241-12/+16
| | | | | | | (GH-123929) (#125937) gh-123930: Better error for "from imports" when script shadows module (#123929) (cherry picked from commit 500f5338a8fe13719478589333fcd296e8e8eb02)
* [3.13] gh-125590: Allow FrameLocalsProxy to delete and pop keys from extra ↵Miss Islington (bot)2024-10-211-6/+70
| | | | | | | | locals (GH-125616) (#125797) gh-125590: Allow FrameLocalsProxy to delete and pop keys from extra locals (GH-125616) (cherry picked from commit 5b7a872b26a9ba6c93d7c2109559a82d1c1612de) Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
* [3.13] gh-125221: Fix free-threading data race in `object.__reduce_ex__` ↵Miss Islington (bot)2024-10-112-15/+13
| | | | | | | | (GH-125267) (#125305) gh-125221: Fix free-threading data race in `object.__reduce_ex__` (GH-125267) (cherry picked from commit b12e99261e656585ffbaa395af7c5dbaee5ad1ad) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-123378: fix a crash in `UnicodeError.__str__` (GH-124935) (#125099)Miss Islington (bot)2024-10-081-45/+66
| | | | | | gh-123378: fix a crash in `UnicodeError.__str__` (GH-124935) (cherry picked from commit ba14dfafd97d1fd03938ac8ddec4ca5b2f12985d) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* [3.13] Fix typos (#123775) (#123866)Victor Stinner2024-10-073-3/+3
| | | | | | | Fix typos (#123775) (cherry picked from commit 9017b95ff2dcff16bcb0b0a609ed2b0daa845943) Co-authored-by: algonell <algonell@gmail.com>
* [3.13] gh-124785: Revert "gh-116510: Fix crash due to shared immortal ↵Miss Islington (bot)2024-10-011-42/+6
| | | | | | | | | | | | interned strings (gh-124646)" (gh-124807) (#124812) gh-124785: Revert "gh-116510: Fix crash due to shared immortal interned strings (gh-124646)" (gh-124807) Revert "gh-116510: Fix crash due to shared immortal interned strings. (gh-124646)" This reverts commit 98b2ed7e239c807f379cd2bf864f372d79064aac. (cherry picked from commit 7bdfabe2d1ec353ecdc75a5aec41cce83e572391) Co-authored-by: T. Wouters <thomas@python.org>
* [3.13] gh-124642: Dictionaries aren't marking objects as weakref'd ↵Miss Islington (bot)2024-09-301-3/+3
| | | | | | | | | | (GH-124643) (#124798) gh-124642: Dictionaries aren't marking objects as weakref'd (GH-124643) Dictionaries aren't marking objects as weakref'd (cherry picked from commit 077e7ef6a0abbf9e04b9aa11b4f621031004c31f) Co-authored-by: Dino Viehland <dinoviehland@meta.com>
* [3.13] gh-123339: Fix cases of inconsistency of __module__ and ↵Serhiy Storchaka2024-09-301-0/+3
| | | | | | | | | | | | | __firstlineno__ in classes (GH-123613) (#124735) * Setting the __module__ attribute for a class now removes the __firstlineno__ item from the type's dict. * The _collections_abc and _pydecimal modules now completely replace the collections.abc and decimal modules after importing them. This allows to get the source of classes and functions defined in these modules. * inspect.findsource() now checks whether the first line number for a class is out of bound. (cherry picked from commit 69a4063ca516360b5eb96f5432ad9f9dfc32a72e)
* [3.13] gh-123826: Fix unused function warnings in mimalloc on NetBSD ↵Miss Islington (bot)2024-09-301-2/+2
| | | | | | | | (GH-123827) (#123875) gh-123826: Fix unused function warnings in mimalloc on NetBSD (GH-123827) (cherry picked from commit 4a6b1f179667e2a8c6131718eb78a15f726e047b) Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
* [3.13] gh-77894: Fix a crash when the GC breaks a loop containing a ↵Miss Islington (bot)2024-09-301-28/+27
| | | | | | | | | | | memoryview (GH-123898) (#123936) gh-77894: Fix a crash when the GC breaks a loop containing a memoryview (GH-123898) Now a memoryview object can only be cleared if there are no buffers that refer it. (cherry picked from commit a1dbf2ea69acc6ccee6292709af1dadd55c068be) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] gh-124513: Check args in framelocalsproxy_new() (GH-124515) (#124539)Miss Islington (bot)2024-09-301-3/+20
| | | | | | | | | gh-124513: Check args in framelocalsproxy_new() (GH-124515) Fix a crash in FrameLocalsProxy constructor: check the number of arguments. (cherry picked from commit d6954b6421aa34afd280df9c44ded21a2348a6ea) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-124498: Fix `TypeAliasType` not to be generic, when ↵Miss Islington (bot)2024-09-301-1/+10
| | | | | | | | `type_params=()` (GH-124499) (#124603) gh-124498: Fix `TypeAliasType` not to be generic, when `type_params=()` (GH-124499) (cherry picked from commit abe5f799e6ce1d177f79554f1b84d348b6141045) Co-authored-by: sobolevn <mail@sobolevn.me>
* [3.13] GH-124547: Clear instance dictionary if memory error occurs during ↵Miss Islington (bot)2024-09-271-2/+9
| | | | | | | | object dealloc (GH-124627) (#124714) GH-124547: Clear instance dictionary if memory error occurs during object dealloc (GH-124627) (cherry picked from commit 0e21cc6cf820679439d72e3ebd06227ee2a085f9) Co-authored-by: Mark Shannon <mark@hotpy.org>
* [3.13] gh-119004: fix a crash in equality testing between `OrderedDict` ↵Miss Islington (bot)2024-09-271-8/+25
| | | | | | | | (GH-121329) (#124507) gh-119004: fix a crash in equality testing between `OrderedDict` (GH-121329) (cherry picked from commit 38a887dc3ec52c4a7222279bf4b3ca2431b86de9) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* [3.13] gh-116510: Fix crash due to shared immortal interned strings. ↵Miss Islington (bot)2024-09-271-6/+42
| | | | | | | | (gh-124646) (#124648) gh-116510: Fix crash due to shared immortal interned strings. (gh-124646) (cherry picked from commit 98b2ed7e239c807f379cd2bf864f372d79064aac) Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
* [3.13] gh-124538: Fix crash when using `gc.get_referents` on an untracked ↵Miss Islington (bot)2024-09-261-3/+7
| | | | | | | | capsule object (GH-124559) (#124588) gh-124538: Fix crash when using `gc.get_referents` on an untracked capsule object (GH-124559) (cherry picked from commit f923605658a29ff9af5a62edc1fc10191977627b) Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* [3.13] gh-123091: Use more _Py_IsImmortalLoose() (GH-123602) (GH-123622)Petr Viktorin2024-09-031-1/+1
| | | | | | | | | Switch more _Py_IsImmortal(...) assertions to _Py_IsImmortalLoose(...) The remaining calls to _Py_IsImmortal are in free-threaded-only code, initialization of core objects, tests, and guards that fall back to code that works with mortal objects. (cherry picked from commit 57c471a6880956338549380fc5fb35c986937901)
* [3.13] gh-123091: Use _Py_IsImmortalLoose() (#123511) (#123600)Victor Stinner2024-09-022-7/+7
| | | | | | | | gh-123091: Use _Py_IsImmortalLoose() (#123511) Use _Py_IsImmortalLoose() in bytesobject.c, typeobject.c and ceval.c. (cherry picked from commit f1a0d96f41db9dfa5d7f0b32e72f6f7301a86f91)
* [3.13] gh-122688: Fix support of var-positional parameter in Argument Clinic ↵Serhiy Storchaka2024-09-021-12/+6
| | | | | | | | | | (GH-122689) (#122852) * Parameters after the var-positional parameter are now keyword-only instead of positional-or-keyword. * Correctly calculate min_kw_only. * Raise errors for invalid combinations of the var-positional parameter with "*", "/" and deprecation markers. (cherry picked from commit 8393608dd9f157ae25ee44777541e62fa80a6d82)
* [3.13] gh-122527: Fix a crash on deallocation of `PyStructSequence` ↵Miss Islington (bot)2024-09-021-6/+22
| | | | | | | | | | | | | | | | | | | | (GH-122577) (#122625) gh-122527: Fix a crash on deallocation of `PyStructSequence` (GH-122577) The `PyStructSequence` destructor would crash if it was deallocated after its type's dictionary was cleared by the GC, because it couldn't compute the "real size" of the instance. This could occur with relatively straightforward code in the free-threaded build or with a reference cycle involving the type in the default build, due to differing orders in which `tp_clear()` was called. Account for the non-sequence fields in `tp_basicsize` and use that, along with `Py_SIZE()`, to compute the "real" size of a `PyStructSequence` in the dealloc function. This avoids the accesses to the type's dictionary during dealloc, which were unsafe. (cherry picked from commit 4b63cd170e5dd840bffc80922f09f2d69932ff5c) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-123448: Move `_PyNoDefault_Type` to the static types array ↵Miss Islington (bot)2024-08-291-0/+1
| | | | | | | (GH-123449) (#123450) (cherry picked from commit c9930f5022f5e7a290896522280e47a1fecba38a) Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* [3.13] gh-122982: Extend the deprecation period for bool inversion by two ↵Miss Islington (bot)2024-08-251-2/+2
| | | | | | | | years (GH-123306) (#123316) gh-122982: Extend the deprecation period for bool inversion by two years (GH-123306) (cherry picked from commit 249b083ed8b3cfdff30bf578d7f9d3c5e982a4eb) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* [3.13] GH-120097: Make FrameLocalsProxy a mapping (GH-120101) (GH-120749)Miss Islington (bot)2024-08-231-1/+1
| | | Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
* [3.13] gh-123083: Fix a potential use-after-free in ``STORE_ATTR_WITH… ↵Donghee Na2024-08-221-0/+2
| | | | | | (#123235) [3.13] gh-123083: Fix a potential use-after-free in ``STORE_ATTR_WITH_HINT`` (gh-123092) (cherry picked from commit 297f2e093ec95800ae2184330b8408c875523467)
* [3.13] gh-123022: Fix crash with `Py_Initialize` in background thread ↵Miss Islington (bot)2024-08-171-4/+12
| | | | | | | | | | | | | | | | | (GH-123052) (#123114) Check that the current default heap is initialized in `_mi_os_get_aligned_hint` and `mi_os_claim_huge_pages`. The mimalloc function `_mi_os_get_aligned_hint` assumes that there is an initialized default heap. This is true for our main thread, but not for background threads. The problematic code path is usually called during initialization (i.e., `Py_Initialize`), but it may also be called if the program allocates large amounts of memory in total. The crash only affected the free-threaded build. (cherry picked from commit d061ffea7b408861d0a9d311e92c363da284971d) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-122888: Fix crash on certain calls to str() (GH-122889) (#122947)Miss Islington (bot)2024-08-121-1/+10
| | | | | | Fixes GH-122888 (cherry picked from commit 53ebb6232a8ebc03827cf2251bfc67f1886ffd70) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>