python / python/cpython

Behaviour change in defaultdict.__missing__ between 3.13.11 and 3.13.12

Open
#148,242 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

I have observed a subtle change in behavior of defaultdict.__missing__ between Python 3.13.11 and 3.13.12. Consider the following output:

3.13.11:

$ uv run --python 3.13.11 python -c 'from collections import defaultdict; print(defaultdict(lambda: "A", {None: "B"}).__missing__(None))'
Using CPython 3.13.11
Creating virtual environment at: .venv
      Built pdonnx @ file:///Users/christian.bourjau/repos/pdonnx
Installed 1 package in 1ms
A

3.13.12:

$ uv run --python 3.13.12 python -c 'from collections import defaultdict; print(defaultdict(lambda: "A", {None: "B"}).__missing__(None))'
Using CPython 3.13.12
Removed virtual environment at: .venv
Creating virtual environment at: .venv
Installed 1 package in 1ms
B

The same change in behavior can be observed between 3.14.2 and 3.14.3.

This might be related to #142495 and https://github.com/python/cpython/pull/142668

Was this an intentional fix?

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Linked PRs
  • gh-148880
  • gh-148881

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported defaultdict.missing(None) behavior on Python 3.13.11, 3.13.12, 3.14.2, and 3.14.3, then read the context in issues #142495 and pull request #142668. Review linked PRs gh-148880 and gh-148881; the work is done when the intended behavior is established and the issue has a clear conclusion or follow-up.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.