diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index 2fe76a3d6..6a4ed891f 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -33,6 +33,8 @@ class XMLParserType: def ExternalEntityParserCreate(self, __context: str | None, __encoding: str = ...) -> XMLParserType: ... def SetParamEntityParsing(self, __flag: int) -> int: ... def UseForeignDTD(self, __flag: bool = ...) -> None: ... + @property + def intern(self) -> dict[str, str]: ... buffer_size: int buffer_text: bool buffer_used: int @@ -69,6 +71,7 @@ class XMLParserType: DefaultHandlerExpand: Callable[[str], Any] | None NotStandaloneHandler: Callable[[], int] | None ExternalEntityRefHandler: Callable[[str, str | None, str | None, str | None], int] | None + SkippedEntityHandler: Callable[[str, bool], Any] | None def ErrorString(__code: int) -> str: ... diff --git a/stdlib/pyexpat/errors.pyi b/stdlib/pyexpat/errors.pyi index 61826e12d..2e512eb12 100644 --- a/stdlib/pyexpat/errors.pyi +++ b/stdlib/pyexpat/errors.pyi @@ -1,3 +1,5 @@ +import sys + codes: dict[str, int] messages: dict[int, str] @@ -38,3 +40,10 @@ XML_ERROR_UNDEFINED_ENTITY: str XML_ERROR_UNEXPECTED_STATE: str XML_ERROR_UNKNOWN_ENCODING: str XML_ERROR_XML_DECL: str +if sys.version_info >= (3, 11): + XML_ERROR_RESERVED_PREFIX_XML: str + XML_ERROR_RESERVED_PREFIX_XMLNS: str + XML_ERROR_RESERVED_NAMESPACE_URI: str + XML_ERROR_INVALID_ARGUMENT: str + XML_ERROR_NO_BUFFER: str + XML_ERROR_AMPLIFICATION_LIMIT_BREACH: str diff --git a/stdlib/xml/sax/handler.pyi b/stdlib/xml/sax/handler.pyi index 3a5193300..abf124f83 100644 --- a/stdlib/xml/sax/handler.pyi +++ b/stdlib/xml/sax/handler.pyi @@ -1,6 +1,6 @@ -from typing import Any +import sys -version: Any +version: str class ErrorHandler: def error(self, exception): ... @@ -30,17 +30,25 @@ class DTDHandler: class EntityResolver: def resolveEntity(self, publicId, systemId): ... -feature_namespaces: Any -feature_namespace_prefixes: Any -feature_string_interning: Any -feature_validation: Any -feature_external_ges: Any -feature_external_pes: Any -all_features: Any -property_lexical_handler: Any -property_declaration_handler: Any -property_dom_node: Any -property_xml_string: Any -property_encoding: Any -property_interning_dict: Any -all_properties: Any +feature_namespaces: str +feature_namespace_prefixes: str +feature_string_interning: str +feature_validation: str +feature_external_ges: str +feature_external_pes: str +all_features: list[str] +property_lexical_handler: str +property_declaration_handler: str +property_dom_node: str +property_xml_string: str +property_encoding: str +property_interning_dict: str +all_properties: list[str] + +if sys.version_info >= (3, 10): + class LexicalHandler: + def comment(self, content: str) -> object: ... + def startDTD(self, name: str, public_id: str | None, system_id: str | None) -> object: ... + def endDTD(self) -> object: ... + def startCDATA(self) -> object: ... + def endCDATA(self) -> object: ... diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index ab2da8eee..20e5cd202 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -94,13 +94,8 @@ multiprocessing.managers.SharedMemoryServer.public multiprocessing.managers.SharedMemoryServer.release_segment multiprocessing.managers.SharedMemoryServer.shutdown multiprocessing.managers.SharedMemoryServer.track_segment -pyexpat.XMLParserType.SkippedEntityHandler -pyexpat.XMLParserType.intern typing._SpecialForm.__call__ unicodedata.UCD.is_normalized -xml.parsers.expat.XMLParserType.SkippedEntityHandler -xml.parsers.expat.XMLParserType.intern -xml.sax.handler.LexicalHandler # ========== # Related to positional-only arguments diff --git a/tests/stubtest_allowlists/py311.txt b/tests/stubtest_allowlists/py311.txt index dc2c5dcf1..a42ea8c5b 100644 --- a/tests/stubtest_allowlists/py311.txt +++ b/tests/stubtest_allowlists/py311.txt @@ -78,14 +78,6 @@ platform.uname_result.processor pydoc.HTMLDoc.heading pydoc.HTMLDoc.multicolumn pydoc.HTMLDoc.section -pyexpat.XMLParserType.SkippedEntityHandler -pyexpat.XMLParserType.intern -pyexpat.errors.XML_ERROR_AMPLIFICATION_LIMIT_BREACH -pyexpat.errors.XML_ERROR_INVALID_ARGUMENT -pyexpat.errors.XML_ERROR_NO_BUFFER -pyexpat.errors.XML_ERROR_RESERVED_NAMESPACE_URI -pyexpat.errors.XML_ERROR_RESERVED_PREFIX_XML -pyexpat.errors.XML_ERROR_RESERVED_PREFIX_XMLNS queue.SimpleQueue.__init__ shutil.rmtree socketserver.UDPServer.allow_reuse_port @@ -117,15 +109,6 @@ unittest.doModuleCleanups urllib.request.FancyURLopener.http_error_308 urllib.request.HTTPRedirectHandler.http_error_308 weakref.WeakValueDictionary.update -xml.parsers.expat.XMLParserType.SkippedEntityHandler -xml.parsers.expat.XMLParserType.intern -xml.parsers.expat.errors.XML_ERROR_AMPLIFICATION_LIMIT_BREACH -xml.parsers.expat.errors.XML_ERROR_INVALID_ARGUMENT -xml.parsers.expat.errors.XML_ERROR_NO_BUFFER -xml.parsers.expat.errors.XML_ERROR_RESERVED_NAMESPACE_URI -xml.parsers.expat.errors.XML_ERROR_RESERVED_PREFIX_XML -xml.parsers.expat.errors.XML_ERROR_RESERVED_PREFIX_XMLNS -xml.sax.handler.LexicalHandler xmlrpc.server.SimpleXMLRPCRequestHandler.rpc_paths zipfile.Path.stem zipfile.Path.suffix diff --git a/tests/stubtest_allowlists/py36.txt b/tests/stubtest_allowlists/py36.txt index 58a052d7f..ad2c4218e 100644 --- a/tests/stubtest_allowlists/py36.txt +++ b/tests/stubtest_allowlists/py36.txt @@ -177,3 +177,6 @@ sqlite3.dbapi2.Binary.__iter__ # C type that implements __getitem__ sqlite3.dbapi2.Binary.cast # inspect.signature is incorrect about shape being kw-only sqlite3.Binary.__iter__ # C type that implements __getitem__ sqlite3.Binary.cast # inspect.signature is incorrect about shape being kw-only + +pyexpat.XMLParserType.intern # does exist but stubtest can't see it (https://github.com/python/cpython/blob/3.7/Modules/pyexpat.c#L1322) +xml.parsers.expat.XMLParserType.intern # does exist but stubtest can't see it (https://github.com/python/cpython/blob/3.7/Modules/pyexpat.c#L1322) diff --git a/tests/stubtest_allowlists/py37.txt b/tests/stubtest_allowlists/py37.txt index c5aac0550..f73afbe06 100644 --- a/tests/stubtest_allowlists/py37.txt +++ b/tests/stubtest_allowlists/py37.txt @@ -170,6 +170,8 @@ queue.SimpleQueue.__init__ pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args xml.parsers.expat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args +pyexpat.XMLParserType.intern # does exist but stubtest can't see it (https://github.com/python/cpython/blob/3.7/Modules/pyexpat.c#L1322) +xml.parsers.expat.XMLParserType.intern # does exist but stubtest can't see it (https://github.com/python/cpython/blob/3.7/Modules/pyexpat.c#L1322) # White lies around defaults dataclasses.field diff --git a/tests/stubtest_allowlists/py38.txt b/tests/stubtest_allowlists/py38.txt index 05b9a604c..3d4c0d6e7 100644 --- a/tests/stubtest_allowlists/py38.txt +++ b/tests/stubtest_allowlists/py38.txt @@ -129,8 +129,6 @@ multiprocessing.managers.SharedMemoryServer.shutdown multiprocessing.managers.SharedMemoryServer.track_segment plistlib.Data.asBase64 plistlib.Data.fromBase64 -pyexpat.XMLParserType.SkippedEntityHandler -pyexpat.XMLParserType.intern stringprep.unicodedata # re-exported from unicodedata tempfile.SpooledTemporaryFile.softspace tkinter.Tk.split @@ -153,8 +151,6 @@ tkinter.simpledialog.wantobjects tkinter.tix.wantobjects typing._SpecialForm.__call__ unicodedata.UCD.is_normalized -xml.parsers.expat.XMLParserType.SkippedEntityHandler -xml.parsers.expat.XMLParserType.intern # ========== # Allowlist entries that cannot or should not be fixed diff --git a/tests/stubtest_allowlists/py39.txt b/tests/stubtest_allowlists/py39.txt index 6b269829c..248874679 100644 --- a/tests/stubtest_allowlists/py39.txt +++ b/tests/stubtest_allowlists/py39.txt @@ -132,15 +132,11 @@ multiprocessing.managers.SharedMemoryServer.public multiprocessing.managers.SharedMemoryServer.release_segment multiprocessing.managers.SharedMemoryServer.shutdown multiprocessing.managers.SharedMemoryServer.track_segment -pyexpat.XMLParserType.SkippedEntityHandler -pyexpat.XMLParserType.intern stringprep.unicodedata # re-exported from unicodedata types.GenericAlias.__mro_entries__ typing._SpecialForm.__call__ typing._SpecialForm.__mro_entries__ unicodedata.UCD.is_normalized -xml.parsers.expat.XMLParserType.SkippedEntityHandler -xml.parsers.expat.XMLParserType.intern # SpooledTemporaryFile implements IO except these methods before Python 3.11 # See also https://github.com/python/typeshed/pull/2452#issuecomment-420657918