From 560f6ddd32505b127e13bfa699f2cf35d11ad445 Mon Sep 17 00:00:00 2001 From: Semyon Moroz Date: Fri, 10 Oct 2025 20:23:39 +0400 Subject: [PATCH] [html.parser] Fix stubtest for later patch releases (#14861) --- stdlib/@tests/stubtest_allowlists/darwin-py310.txt | 8 ++++++++ stdlib/@tests/stubtest_allowlists/darwin-py311.txt | 8 ++++++++ stdlib/@tests/stubtest_allowlists/darwin-py312.txt | 8 ++++++++ stdlib/@tests/stubtest_allowlists/darwin-py39.txt | 8 ++++++++ stdlib/@tests/stubtest_allowlists/win32-py310.txt | 8 ++++++++ stdlib/@tests/stubtest_allowlists/win32-py311.txt | 8 ++++++++ stdlib/@tests/stubtest_allowlists/win32-py312.txt | 8 ++++++++ stdlib/@tests/stubtest_allowlists/win32-py39.txt | 8 ++++++++ stdlib/html/parser.pyi | 13 ++++--------- 9 files changed, 68 insertions(+), 9 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/darwin-py310.txt b/stdlib/@tests/stubtest_allowlists/darwin-py310.txt index cc1ebe489..331f922da 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin-py310.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin-py310.txt @@ -1,3 +1,11 @@ +# ======= +# <= 3.12 +# ======= + +# Added in Python 3.10.18 (parameter `escapable`) +html.parser.HTMLParser.set_cdata_mode + + # ======= # <= 3.11 # ======= diff --git a/stdlib/@tests/stubtest_allowlists/darwin-py311.txt b/stdlib/@tests/stubtest_allowlists/darwin-py311.txt index 77dc5722a..2d8079d43 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin-py311.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin-py311.txt @@ -8,6 +8,14 @@ fcntl.F_OFD_SETLK fcntl.F_OFD_SETLKW +# ======= +# <= 3.12 +# ======= + +# Added in Python 3.11.13 (parameter `escapable`) +html.parser.HTMLParser.set_cdata_mode + + # ======= # <= 3.11 # ======= diff --git a/stdlib/@tests/stubtest_allowlists/darwin-py312.txt b/stdlib/@tests/stubtest_allowlists/darwin-py312.txt index cfe4e918f..c81581eb7 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin-py312.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin-py312.txt @@ -8,6 +8,14 @@ fcntl.F_OFD_SETLK fcntl.F_OFD_SETLKW +# ======= +# <= 3.12 +# ======= + +# Added in Python 3.12.11 (parameter `escapable`) +html.parser.HTMLParser.set_cdata_mode + + # ============================================================= # Allowlist entries that cannot or should not be fixed; <= 3.12 # ============================================================= diff --git a/stdlib/@tests/stubtest_allowlists/darwin-py39.txt b/stdlib/@tests/stubtest_allowlists/darwin-py39.txt index e11829830..59728a27f 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin-py39.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin-py39.txt @@ -1,3 +1,11 @@ +# ======= +# <= 3.12 +# ======= + +# Added in Python 3.9.23 (parameter `escapable`) +html.parser.HTMLParser.set_cdata_mode + + # ======= # <= 3.11 # ======= diff --git a/stdlib/@tests/stubtest_allowlists/win32-py310.txt b/stdlib/@tests/stubtest_allowlists/win32-py310.txt index ca56d2f0e..a49447e79 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py310.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py310.txt @@ -1,3 +1,11 @@ +# ======= +# <= 3.12 +# ======= + +# Added in Python 3.10.18 (parameter `escapable`) +html.parser.HTMLParser.set_cdata_mode + + # ======= # <= 3.11 # ======= diff --git a/stdlib/@tests/stubtest_allowlists/win32-py311.txt b/stdlib/@tests/stubtest_allowlists/win32-py311.txt index fe33c11f3..62c544055 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py311.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py311.txt @@ -1,3 +1,11 @@ +# ======= +# <= 3.12 +# ======= + +# Added in Python 3.11.13 (parameter `escapable`) +html.parser.HTMLParser.set_cdata_mode + + # ======= # <= 3.11 # ======= diff --git a/stdlib/@tests/stubtest_allowlists/win32-py312.txt b/stdlib/@tests/stubtest_allowlists/win32-py312.txt index 3e5762cbf..1c808d36d 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py312.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py312.txt @@ -16,6 +16,14 @@ _winapi.GetLongPathName _winapi.GetShortPathName +# ======= +# <= 3.12 +# ======= + +# Added in Python 3.12.11 (parameter `escapable`) +html.parser.HTMLParser.set_cdata_mode + + # ============================================================= # Allowlist entries that cannot or should not be fixed; <= 3.12 # ============================================================= diff --git a/stdlib/@tests/stubtest_allowlists/win32-py39.txt b/stdlib/@tests/stubtest_allowlists/win32-py39.txt index 41f8ff3af..ace75c0b6 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py39.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py39.txt @@ -1,3 +1,11 @@ +# ======= +# <= 3.12 +# ======= + +# Added in Python 3.9.23 (parameter `escapable`) +html.parser.HTMLParser.set_cdata_mode + + # ======= # <= 3.11 # ======= diff --git a/stdlib/html/parser.pyi b/stdlib/html/parser.pyi index 8b3fce001..7edd39e8c 100644 --- a/stdlib/html/parser.pyi +++ b/stdlib/html/parser.pyi @@ -1,4 +1,3 @@ -import sys from _markupbase import ParserBase from re import Pattern from typing import Final @@ -7,9 +6,8 @@ __all__ = ["HTMLParser"] class HTMLParser(ParserBase): CDATA_CONTENT_ELEMENTS: Final[tuple[str, ...]] - if sys.version_info >= (3, 13): - # Added in 3.13.6 - RCDATA_CONTENT_ELEMENTS: Final[tuple[str, ...]] + # Added in Python 3.9.23, 3.10.18, 3.11.13, 3.12.11, 3.13.6 + RCDATA_CONTENT_ELEMENTS: Final[tuple[str, ...]] def __init__(self, *, convert_charrefs: bool = True) -> None: ... def feed(self, data: str) -> None: ... @@ -32,11 +30,8 @@ class HTMLParser(ParserBase): def parse_html_declaration(self, i: int) -> int: ... # undocumented def parse_pi(self, i: int) -> int: ... # undocumented def parse_starttag(self, i: int) -> int: ... # undocumented - if sys.version_info >= (3, 13): - # `escapable` parameter added in 3.13.6 - def set_cdata_mode(self, elem: str, *, escapable: bool = False) -> None: ... # undocumented - else: - def set_cdata_mode(self, elem: str) -> None: ... # undocumented + # `escapable` parameter added in Python 3.9.23, 3.10.18, 3.11.13, 3.12.11, 3.13.6 + def set_cdata_mode(self, elem: str, *, escapable: bool = False) -> None: ... # undocumented rawdata: str # undocumented cdata_elem: str | None # undocumented convert_charrefs: bool # undocumented