gh-140551: Fix dict crash if clear is called at lookup stage#140558
gh-140551: Fix dict crash if clear is called at lookup stage#140558kumaraditya303 merged 11 commits intopython:mainfrom
dict crash if clear is called at lookup stage#140558Conversation
Misc/NEWS.d/next/Core_and_Builtins/2025-10-24-20-42-33.gh-issue-140551.-9swrl.rst
Outdated
Show resolved
Hide resolved
|
For the following repro: It crashes inside |
|
For the following repro: It crashes also inside Both repro tests on Windows 11 on main branch. |
…e-140551.-9swrl.rst Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
|
Another one I found on main: It is aborted with |
Yes, it's expected that |
|
I'm not sure if this is the correct solution. If the keys of a dictionary change during a dict lookup, can we trust the result of the lookup (e.g. Shouldn't it raise an error if the keys of a dict change during a lookup? |
|
I like this error: PyErr_SetString(PyExc_RuntimeError,
"dict mutated during update"); |
CPython behavior has been to retry the lookup if the key changes (since Python 2.2, 453163d). I don't think we should change it. |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
IIUC, problem is fixed and CI is green. |
|
Thanks @efimov-mikhail for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
|
Sorry, @efimov-mikhail and @kumaraditya303, I could not cleanly backport this to |
|
Sorry, @efimov-mikhail and @kumaraditya303, I could not cleanly backport this to |
|
Thanks for the merge, @kumaraditya303. |
…age (python#140558) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
|
GH-140743 is a backport of this pull request to the 3.14 branch. |
…age (python#140558) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
|
GH-140744 is a backport of this pull request to the 3.13 branch. |
|
FYI, @kumaraditya303 |
This fixes a regression introduced in pythongh-140558. The interpreter would crash if we inserted a non `str` key into a split table that matches an existing key.
This fixes a regression introduced in pythongh-140558. The interpreter would crash if we inserted a non `str` key into a split table that matches an existing key. (cherry picked from commit 547d8da) Co-authored-by: Sam Gross <colesbury@gmail.com>
…2229) This fixes a regression introduced in pythongh-140558. The interpreter would crash if we inserted a non `str` key into a split table that matches an existing key. (cherry picked from commit 547d8da) Co-authored-by: Sam Gross <colesbury@gmail.com>
…age (python#140558) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
This fixes a regression introduced in pythongh-140558. The interpreter would crash if we inserted a non `str` key into a split table that matches an existing key.
dictifhash__eq__function has side effects #140551