python / python/cpython

Behaviour change in defaultdict.__missing__ between 3.13.11 and 3.13.12

オープン
#148,242 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stdlib type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず Python 3.13.11、3.13.12、3.14.2、3.14.3 で報告された defaultdict.missing(None) の挙動を再現し、次に issues #142495 と pull request #142668 のコンテキストを読んでください。リンクされている PRs gh-148880 と gh-148881 を確認してください。意図された挙動が確立され、issue に明確な結論または follow-up があるとき、作業は完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。