Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-143189: fix insertdict() for non-Unicode key#143285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hugovk merged 3 commits intopython:mainfrommethane:fix-143189-dict-insert
Jan 12, 2026

Conversation

@methane
Copy link
Member

@methanemethane commentedDec 30, 2025
edited by bedevere-appbot
Loading

When iserting non unicode key into split table, matching Unicode key may be in the shared split table without its value.

When iserting non unicode key into split table, matching Unicode keymay be in the shared split table without its value.
@methanemethane added interpreter-core(Objects, Python, Grammar, and Parser dirs) needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsDec 30, 2025
Copy link

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull request overview

This PR fixes a crash in the CPython dictionary implementation when inserting a non-str key (specifically astr subclass) into a split table dictionary where the key matches an existing key in the shared split table but has no corresponding value in the instance dictionary yet.

Key Changes:

  • Fixed the logic ininsertdict() to checkold_value == NULL instead ofix == DKIX_EMPTY to properly handle split tables where a key exists without a value
  • Added explanatory comments documenting this edge case behavior
  • Added test coverage for the specific scenario that was causing the crash

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

FileDescription
Objects/dictobject.cFixed the condition check ininsertdict() to useold_value == NULL instead ofix == DKIX_EMPTY and added clarifying comments about split table behavior
Misc/NEWS.d/next/Core_and_Builtins/2025-12-30-06-48-48.gh-issue-143189.in_sv2.rstAdded changelog entry describing the crash fix
Lib/test/test_dict.pyAdded new test casetest_split_table_insert_with_str_subclass to verify the fix works correctly

💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.

obj2 = MyClass()
d = obj2.__dict__
d[MyStr("attr1")] = 2
assert isinstance(list(d)[0], MyStr)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Use unittest assertion method instead of bare assert statement. This ensures the test properly reports failures with helpful messages and follows unittest best practices. Replace withself.assertTrue(isinstance(list(d)[0], MyStr)).

Suggested change
assertisinstance(list(d)[0],MyStr)
self.assertTrue(isinstance(list(d)[0],MyStr))

Copilot uses AI. Check for mistakes.
@hugovkhugovk merged commit43c7658 intopython:mainJan 12, 2026
50 checks passed
@miss-islington-app
Copy link

Thanks@methane for the PR, and@hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry,@methane and@hugovk, I could not cleanly backport this to3.14 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker 43c76587c1ba2c3937fa6834db10cffc604e39e0 3.14

@miss-islington-app
Copy link

Sorry,@methane and@hugovk, I could not cleanly backport this to3.13 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker 43c76587c1ba2c3937fa6834db10cffc604e39e0 3.13

@hugovk
Copy link
Member

@methane Please can you check the backports?

reidenong pushed a commit to reidenong/cpython that referenced this pull requestJan 12, 2026
@methanemethane deleted the fix-143189-dict-insert branchJanuary 13, 2026 04:49
@bedevere-app
Copy link

GH-143771 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelJan 13, 2026
@bedevere-app
Copy link

GH-143772 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelJan 13, 2026
methane added a commit to methane/cpython that referenced this pull requestJan 13, 2026
…H-143285)(cherry picked from commit43c7658)Co-authored-by: Inada Naoki <songofacandy@gmail.com>
@methanemethane added the type-crashA hard crash of the interpreter, possibly with a core dump labelJan 13, 2026
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@colesburycolesburycolesbury approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

Assignees

@hugovkhugovk

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@methane@hugovk@colesbury

[8]ページ先頭

©2009-2026 Movatter.jp