Skip to content

gh-148242: Full restoration of the historical behavior of defaultdict, without losing thread safety - #148880

Open
Changaco wants to merge 13 commits into
python:mainfrom
Changaco:defaultdict-freethreading
Open

gh-148242: Full restoration of the historical behavior of defaultdict, without losing thread safety#148880
Changaco wants to merge 13 commits into
python:mainfrom
Changaco:defaultdict-freethreading

Conversation

@Changaco

@Changaco Changaco commented Apr 22, 2026

Copy link
Copy Markdown

This is one of the possible solutions to #148242. It has the advantage of being transparent to users since it doesn't break any existing code. The downside is that it doesn't completely fix the unsafe design of the defaultdict class.

Changes to the private C API (not strictly necessary, could be dropped):

  • the static dict_unhashable_type function becomes the exposed _Py_dict_unhashable_type
  • a _PyCriticalSection_WarnIfNotHeld function is created

Minor fix of the defaultdict.__missing__ docstring.

Alternatives:


📚 Documentation preview 📚: https://cpython-previews--148880.org.readthedocs.build/

@python-cla-bot

python-cla-bot Bot commented Apr 22, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant