summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* [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>
* [3.13] gh-120974: Make asyncio `swap_current_task` safe in free-threaded ↵Miss Islington (bot)2024-08-021-16/+38
| | | | | | | | | | build (GH-122317) (#122612) gh-120974: Make asyncio `swap_current_task` safe in free-threaded build (GH-122317) * gh-120974: Make asyncio `swap_current_task` safe in free-threaded build (cherry picked from commit b5e6fb39a246bf7ee470d58632cdf588bb9d0298) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-120906: Support arbitrary hashable keys in FrameLocalsProxy ↵Petr Viktorin2024-07-311-56/+76
| | | | | | | | | (GH-122309) (#122488) [3.13] gh-120906: Support arbitrary hashable keys in FrameLocalsProxy (GH-122309) Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com> (cherry picked from commit 5912487938ac4b517209082ab9e6d2d3d0fb4f4d)
* [3.13] gh-116622: Fix testPyObjectPrintOSError on Android (GH-122487) (#122490)Miss Islington (bot)2024-07-311-2/+9
| | | | | | | | gh-116622: Fix testPyObjectPrintOSError on Android (GH-122487) Adds extra handling for way BSD/Android return errors from calls to fwrite. (cherry picked from commit 82db5728136ebec3a1d221570b810b4128a21255) Co-authored-by: Malcolm Smith <smith@chaquo.com>
* [3.13] gh-122208: Don't delivery PyDict_EVENT_ADDED until it can't fail ↵Dino Viehland2024-07-301-11/+8
| | | | | (#122326) Don't delivery PyDict_EVENT_ADDED until it can't fail
* [3.13] gh-117482: Fix the Slot Wrapper Inheritance Tests (gh-122249)Eric Snow2024-07-291-4/+19
| | | | | The tests were only checking cases where the slot wrapper was present in the initial case. They were missing when the slot wrapper was added in the additional initializations. This fixes that. (cherry-picked from commit 490e0ad83ac72c5688dfbbab4eac61ccfd7be5fd, AKA gh-122248)
* [3.13] gh-122291: Intern latin-1 one-byte strings at startup (GH-122303) ↵Miss Islington (bot)2024-07-271-27/+9
| | | | | | | (GH-122347) (cherry picked from commit bb09ba679223666e01f8da780f97888a29d07131) Co-authored-by: Petr Viktorin <encukou@gmail.com>
* [3.13] GH-121832: Assert that the version number of static builtin types is ↵Miss Islington (bot)2024-07-251-0/+2
| | | | | | | | | not changed by PyType_Modified (gh-122290) Update datetime module and test_type_cache.py to not call PyType_Modified. (cherry picked from commit e55b05f29ee62cd92b6b9990fd699b78f19432ba, AKA gh--122182) Co-authored-by: Mark Shannon <mark@hotpy.org>
* [3.13] gh-116322: Fix typo in the GH-ifdef check (GH-122268) (#122284)Miss Islington (bot)2024-07-251-1/+1
| | | | | | gh-116322: Fix typo in the GH-ifdef check (GH-122268) (cherry picked from commit 9bb2e4623f504c44655436eae181d802f544fff9) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] gh-117482: Simplify the Fix For Builtin Types Slot Wrappers (gh-121932)Eric Snow2024-07-241-30/+93
| | | | | | | | | | | | | | | In gh-121602, I applied a fix to a builtin types initialization bug. That fix made sense in the context of some broader future changes, but introduced a little bit of extra complexity. For earlier versions those future changes are not relevant; we can avoid the extra complexity. Thus we can revert that earlier change and replace it with this one, which is more focused and conceptually simpler. This is essentially the implementation of an idea that @markshannon pointed out to me. Note that this change would be much smaller if we didn't have to deal with repr compatibility for builtin types that explicitly inherit tp slots (see expect_manually_inherited()). The alternative is to stop *explicitly* inheriting tp slots in static PyTypeObject values, which is churn that we can do separately.
* [3.13] gh-120974: Make _asyncio._leave_task atomic in the free-threaded ↵Miss Islington (bot)2024-07-231-15/+15
| | | | | | | | | | | | | build (GH-122139) (#122186) gh-120974: Make _asyncio._leave_task atomic in the free-threaded build (GH-122139) * gh-120974: Make _asyncio._leave_task atomic in the free-threaded build Update `_PyDict_DelItemIf` to allow for an argument to be passed to the predicate. (cherry picked from commit a15feded71dd47202db169613effdafc468a8cf3) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-121266: Remove Py_ALWAYS_INLINE in dictobject.c (GH-121493) (#122095)Miss Islington (bot)2024-07-211-3/+3
| | | | | | | | | | gh-121266: Remove Py_ALWAYS_INLINE in dictobject.c (GH-121493) compare_unicode_generic(), compare_unicode_unicode() and compare_generic() are callbacks used by do_lookup(). When enabling assertions, it's not possible to inline these functions. (cherry picked from commit c5a6b9afd82cad3f6abd9dc71cd5fdd5781a53f5) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-121266: Change dict check_lookup() return type to int (GH-121581) ↵Miss Islington (bot)2024-07-201-11/+11
| | | | | | | | (#121949) gh-121266: Change dict check_lookup() return type to int (GH-121581) (cherry picked from commit 51da3dfbf3782ad678624e720ec3fc8dfff27d16) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-121905: Consistently use "floating-point" instead of "floating ↵Serhiy Storchaka2024-07-194-10/+10
| | | | | point" (GH-121907) (GH-122012) (cherry picked from commit 1a0c7b9ba48a2dffb70bb0c7327abae1d3e87356)
* [3.13] gh-118934: Make PyEval_GetLocals return borrowed reference ↵Miss Islington (bot)2024-07-181-0/+4
| | | | | | | | | (GH-119769) (#121869) gh-118934: Make PyEval_GetLocals return borrowed reference (GH-119769) (cherry picked from commit e65cb4c6f01a687f451ad9db1600525e1c5832c4) Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com> Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
* [3.13] gh-113993: Don't immortalize in PyUnicode_InternInPlace; keep ↵Petr Viktorin2024-07-171-1/+1
| | | | | | | | | | | | | | | | | immortalizing in other API (GH-121364) (GH-121854) * Switch PyUnicode_InternInPlace to _PyUnicode_InternMortal, clarify docs * Document immortality in some functions that take `const char *` This is PyUnicode_InternFromString; PyDict_SetItemString, PyObject_SetAttrString; PyObject_DelAttrString; PyUnicode_InternFromString; and the PyModule_Add convenience functions. Always point out a non-immortalizing alternative. * Don't immortalize user-provided attr names in _ctypes (cherry picked from commit b4aedb23ae7954fb58084dda16cd41786819a8cf)
* [3.13] gh-121863: Immortalize names in code objects to avoid crash ↵Miss Islington (bot)2024-07-171-1/+1
| | | | | | | (GH-121903) (GH-121904) (cherry picked from commit cffad5c6ef9371b26e32556296cea2bfe8358b1a) Co-authored-by: Petr Viktorin <encukou@gmail.com>
* [3.13] gh-121153: Fix some errors with use of _PyLong_CompactValue() ↵Serhiy Storchaka2024-07-171-13/+55
| | | | | | | | | (GH-121154) (GH-121900) * The result has type Py_ssize_t, not intptr_t. * Type cast between unsigned and signed integer types should be explicit. * Downcasting should be explicit. * Fix integer overflow check in sum(). (cherry picked from commit 1801545)
* [3.13] gh-121860: Fix crash when materializing managed dict (GH-121866) ↵Miss Islington (bot)2024-07-161-5/+12
| | | | | | | | | (#121867) The object's inline values may be marked invalid if the materialized dict was already initialized and then deleted. (cherry picked from commit 162b41f57757c1df40eb377985e2e877fb0f0ea3) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-113993: For string interning, do not rely on (or assert) ↵Miss Islington (bot)2024-07-161-7/+8
| | | | | | | | | | | _Py_IsImmortal (GH-121358) (GH-121851) gh-113993: For string interning, do not rely on (or assert) _Py_IsImmortal (GH-121358) Older stable ABI extensions are allowed to make immortal objects mortal. Instead, use `_PyUnicode_STATE` (`interned` and `statically_allocated`). (cherry picked from commit 956270d08d5c23f59937e2f29f8e0b7f63d68afd) Co-authored-by: Petr Viktorin <encukou@gmail.com>
* [3.13] gh-121794: Don't set `ob_tid` to zero in fast-path dealloc ↵Miss Islington (bot)2024-07-151-2/+6
| | | | | | | | | | | | | | | | | (GH-121799) (#121821) We should maintain the invariant that a zero `ob_tid` implies the refcount fields are merged. * Move the assignment in `_Py_MergeZeroLocalRefcount` to immediately before the refcount merge. * Update `_PyTrash_thread_destroy_chain` to set `ob_ref_shared` to `_Py_REF_MERGED` when setting `ob_tid` to zero. Also check this invariant with assertions in the GC in debug builds. That uncovered a bug when running out of memory during GC. (cherry picked from commit d23be3947ced081914f4458c84f729c9c37f0219) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-121731: Fix mimalloc compile error on GNU/Hurd (GH-121732) (#121773)Miss Islington (bot)2024-07-141-0/+1
| | | | | (cherry picked from commit d005f2c1861dbf0ab3d9f80b54d05d0c0b522c3c) Co-authored-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* [3.13] gh-121660: Fix `ga_getitem` by explicitly checking for `NULL` result ↵Miss Islington (bot)2024-07-141-0/+4
| | | | | | | | (GH-121661) (#121761) gh-121660: Fix `ga_getitem` by explicitly checking for `NULL` result (GH-121661) (cherry picked from commit bb802db8cfa35a88582be32fae05fe1cf8f237b1) Co-authored-by: sobolevn <mail@sobolevn.me>
* [3.13] gh-121652: Handle `allocate_weakref` returning NULL (GH-121653) (#121721)Miss Islington (bot)2024-07-131-0/+7
| | | | | | | The `allocate_weakref` may return NULL when out of memory. We need to handle that case and propagate the error. (cherry picked from commit a640a605a8a1a3f73b98f948d0c2a7d42134f692) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-120198: Stop the world when setting __class__ on free-threaded ↵Ken Jin2024-07-122-49/+62
| | | | | build (#121591) (cherry-picked from commit 3bfc9c8)
* [3.13] gh-117482: Fix Builtin Types Slot Wrappers (gh-121630)Miss Islington (bot)2024-07-111-10/+30
| | | | | | | When builtin static types are initialized for a subinterpreter, various "tp" slots have already been inherited (for the main interpreter). This was interfering with the logic in add_operators() (in Objects/typeobject.c), causing a wrapper to get created when it shouldn't. This change fixes that by preserving the original data from the static type struct and checking that. (cherry picked from commit 5250a031332eb9499d5fc190d7287642e5a144b9, AKA gh-121602) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* [3.13] gh-117657: Fix TSan race in _PyDict_CheckConsistency (GH-121551) ↵Miss Islington (bot)2024-07-101-9/+15
| | | | | | | | | (#121590) The only remaining race in dictobject.c was in _PyDict_CheckConsistency when the dictionary has shared keys. (cherry picked from commit 3ec719fabf936ea7a012a76445b860759155de86) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-121460: Skip freeing unallocated arenas (gh-121589)Miss Islington (bot)2024-07-101-0/+8
| | | | | | | | | `munmap(NULL)` is not noop, like `free(NULL)` is. Fixes an observed testsuite hang on 32-bit ARM systems. (cherry picked from commit a802277914405786f6425f2776605c44bd407fc0, AKA gh-121491) Co-authored-by: Stefano Rivera <stefano@rivera.za.net>
* [3.13] GH-121439: Allow PyTupleObjects with an ob_size of 20 in the ↵Miss Islington (bot)2024-07-101-1/+1
| | | | | | | | free_list to be reused (gh-121428) (gh-121565) GH-121439: Allow PyTupleObjects with an ob_size of 20 in the free_list to be reused (gh-121428) (cherry picked from commit 9585a1a2a251aaa15baf6579e13dd3be0cb05f1f) Co-authored-by: satori1995 <132636720+satori1995@users.noreply.github.com>
* [3.13] gh-112075: Fix dict thread safety issues (GH-119288) (#121545)Miss Islington (bot)2024-07-091-25/+41
| | | | | (cherry picked from commit f0ed1863bd7a0b9d021fb59e156663a7ec553f0e) Co-authored-by: Germán Méndez Bravo <kronuz@fb.com>