From 9b683808581f8d535a4f693bed9690ee914aa6da Mon Sep 17 00:00:00 2001 From: Hien Hoang Date: Tue, 27 Oct 2026 09:01:55 +0700 Subject: [PATCH] [email] contains_token_type was backported to 3.11-3.13 Python 3.11.18, 3.12.16 and 3.13.18 add TokenList.contains_token_type and Terminal.contains_token_type, which #16596 added for 3.14.9 and 3.15.1. The daily stubtest run fails on the Ubuntu runners, which already have these releases (#16622). macOS and Windows runners are still on older patches, so the darwin and win32 allowlists carry temporary entries until they update. --- stdlib/@tests/stubtest_allowlists/darwin-py311.txt | 5 +++++ stdlib/@tests/stubtest_allowlists/darwin-py312.txt | 5 +++++ stdlib/@tests/stubtest_allowlists/darwin-py313.txt | 10 ++++++++++ stdlib/@tests/stubtest_allowlists/win32-py311.txt | 5 +++++ stdlib/@tests/stubtest_allowlists/win32-py312.txt | 5 +++++ stdlib/@tests/stubtest_allowlists/win32-py313.txt | 10 ++++++++++ stdlib/email/_header_value_parser.pyi | 8 ++++---- 7 files changed, 44 insertions(+), 4 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/darwin-py311.txt b/stdlib/@tests/stubtest_allowlists/darwin-py311.txt index 58ed2b6b27c7..516e5967141e 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin-py311.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin-py311.txt @@ -45,6 +45,11 @@ html.parser.HTMLParser.__init__ # parameter `scripting` pyexpat.XMLParserType.SetAllocTrackerActivationThreshold pyexpat.XMLParserType.SetAllocTrackerMaximumAmplification +# Incompatible changes introduced in Python 3.11.18 +# (Remove once 3.11.18 becomes available for GitHub Actions) +email._header_value_parser.Terminal.contains_token_type +email._header_value_parser.TokenList.contains_token_type + # ============ # 3.11 to 3.12 diff --git a/stdlib/@tests/stubtest_allowlists/darwin-py312.txt b/stdlib/@tests/stubtest_allowlists/darwin-py312.txt index 38f151441b3b..89dbea997750 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin-py312.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin-py312.txt @@ -32,6 +32,11 @@ html.parser.HTMLParser.__init__ # parameter `scripting` pyexpat.XMLParserType.SetAllocTrackerActivationThreshold pyexpat.XMLParserType.SetAllocTrackerMaximumAmplification +# Incompatible changes introduced in Python 3.12.16 +# (Remove once 3.12.16 becomes available for GitHub Actions) +email._header_value_parser.Terminal.contains_token_type +email._header_value_parser.TokenList.contains_token_type + # ============ # 3.11 to 3.12 diff --git a/stdlib/@tests/stubtest_allowlists/darwin-py313.txt b/stdlib/@tests/stubtest_allowlists/darwin-py313.txt index 681f65781662..bea2b081d446 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin-py313.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin-py313.txt @@ -1,3 +1,13 @@ +# ========= +# Temporary +# ========= + +# Incompatible changes introduced in Python 3.13.18 +# (Remove once 3.13.18 becomes available for GitHub Actions) +email._header_value_parser.Terminal.contains_token_type +email._header_value_parser.TokenList.contains_token_type + + # ============= # 3.13 and 3.14 # ============= diff --git a/stdlib/@tests/stubtest_allowlists/win32-py311.txt b/stdlib/@tests/stubtest_allowlists/win32-py311.txt index 38c8daf436c6..08240209a6b3 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py311.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py311.txt @@ -45,6 +45,11 @@ html.parser.HTMLParser.__init__ # parameter `scripting` pyexpat.XMLParserType.SetAllocTrackerActivationThreshold pyexpat.XMLParserType.SetAllocTrackerMaximumAmplification +# Incompatible changes introduced in Python 3.11.18 +# (Remove once 3.11.18 becomes available for GitHub Actions) +email._header_value_parser.Terminal.contains_token_type +email._header_value_parser.TokenList.contains_token_type + # ============================================================= # Allowlist entries that cannot or should not be fixed; <= 3.12 diff --git a/stdlib/@tests/stubtest_allowlists/win32-py312.txt b/stdlib/@tests/stubtest_allowlists/win32-py312.txt index c22d4e4cf3cf..8a241366f356 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py312.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py312.txt @@ -32,6 +32,11 @@ html.parser.HTMLParser.__init__ # parameter `scripting` pyexpat.XMLParserType.SetAllocTrackerActivationThreshold pyexpat.XMLParserType.SetAllocTrackerMaximumAmplification +# Incompatible changes introduced in Python 3.12.16 +# (Remove once 3.12.16 becomes available for GitHub Actions) +email._header_value_parser.Terminal.contains_token_type +email._header_value_parser.TokenList.contains_token_type + # ======= # >= 3.12 diff --git a/stdlib/@tests/stubtest_allowlists/win32-py313.txt b/stdlib/@tests/stubtest_allowlists/win32-py313.txt index 7fba48d7067a..117ad68c28de 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py313.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py313.txt @@ -1,3 +1,13 @@ +# ========= +# Temporary +# ========= + +# Incompatible changes introduced in Python 3.13.18 +# (Remove once 3.13.18 becomes available for GitHub Actions) +email._header_value_parser.Terminal.contains_token_type +email._header_value_parser.TokenList.contains_token_type + + # ======= # >= 3.12 # ======= diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index 02aff94c7bd3..de974b9c37dd 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -47,8 +47,8 @@ class TokenList(list[TokenList | Terminal]): def as_ew_allowed(self) -> bool: ... @property def comments(self) -> list[str]: ... - if sys.version_info >= (3, 14): - # Added in Python 3.14.9 and 3.15.1. + if sys.version_info >= (3, 11): + # Added in Python 3.11.18, 3.12.16, 3.13.18, 3.14.9 and 3.15.1. def contains_token_type(self, *token_types: str | None) -> bool: ... def fold(self, *, policy: Policy) -> str: ... @@ -343,8 +343,8 @@ class Terminal(str): def pop_trailing_ws(self) -> None: ... @property def comments(self) -> list[str]: ... - if sys.version_info >= (3, 14): - # Added in Python 3.14.9 and 3.15.1. + if sys.version_info >= (3, 11): + # Added in Python 3.11.18, 3.12.16, 3.13.18, 3.14.9 and 3.15.1. def contains_token_type(self, *token_types: str | None) -> bool: ... def __getnewargs__(self) -> tuple[str, str]: ... # type: ignore[override]