Changed behavior of singledispatch in Python 3.12
オープン
@AlexWaygood がすでに取り組んでいます。
2024年3月20日 から。
3.12
3.13
stdlib
topic-typing
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
It seems the behavior of functools.singledispatch changed in Python 3.12 in situations where a typing.Protocol is involved.
When executing the following code on 3.12, MyClass no longer gets dispatched as via the default but as MyProtocol. The problem seems to be that issubclass now behaves differently when called on protocols. The issue was noticed here where it caused downstream problems.
from typing import Protocol
from functools import singledispatch
class MyProtocol(Protocol):
pass
class MyClass:
pass
s = singledispatch(lambda x: "default")
s.register(MyProtocol, lambda x: "protocol")
print(s(MyClass)) # yields "default" on 3.11 but "protocol" on 3.12
CPython versions tested on:
3.11, 3.12
Operating systems tested on:
macOS
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。