Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7cbde0

Browse files
xml: stubtest fixes (#7890)
1 parent 611fa18 commit e7cbde0

9 files changed

Lines changed: 41 additions & 46 deletions

File tree

stdlib/pyexpat/__init__.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class XMLParserType:
3333
def ExternalEntityParserCreate(self, __context: str | None, __encoding: str = ...) -> XMLParserType: ...
3434
def SetParamEntityParsing(self, __flag: int) -> int: ...
3535
def UseForeignDTD(self, __flag: bool = ...) -> None: ...
36+
@property
37+
def intern(self) -> dict[str, str]: ...
3638
buffer_size: int
3739
buffer_text: bool
3840
buffer_used: int
@@ -69,6 +71,7 @@ class XMLParserType:
6971
DefaultHandlerExpand: Callable[[str], Any] | None
7072
NotStandaloneHandler: Callable[[], int] | None
7173
ExternalEntityRefHandler: Callable[[str, str | None, str | None, str | None], int] | None
74+
SkippedEntityHandler: Callable[[str, bool], Any] | None
7275

7376
def ErrorString(__code: int) -> str: ...
7477

stdlib/pyexpat/errors.pyi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
codes: dict[str, int]
24
messages: dict[int, str]
35

@@ -38,3 +40,10 @@ XML_ERROR_UNDEFINED_ENTITY: str
3840
XML_ERROR_UNEXPECTED_STATE: str
3941
XML_ERROR_UNKNOWN_ENCODING: str
4042
XML_ERROR_XML_DECL: str
43+
if sys.version_info >= (3, 11):
44+
XML_ERROR_RESERVED_PREFIX_XML: str
45+
XML_ERROR_RESERVED_PREFIX_XMLNS: str
46+
XML_ERROR_RESERVED_NAMESPACE_URI: str
47+
XML_ERROR_INVALID_ARGUMENT: str
48+
XML_ERROR_NO_BUFFER: str
49+
XML_ERROR_AMPLIFICATION_LIMIT_BREACH: str

stdlib/xml/sax/handler.pyi

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from typing import Any
1+
import sys
22

3-
version: Any
3+
version: str
44

55
class ErrorHandler:
66
def error(self, exception): ...
@@ -30,17 +30,25 @@ class DTDHandler:
3030
class EntityResolver:
3131
def resolveEntity(self, publicId, systemId): ...
3232

33-
feature_namespaces: Any
34-
feature_namespace_prefixes: Any
35-
feature_string_interning: Any
36-
feature_validation: Any
37-
feature_external_ges: Any
38-
feature_external_pes: Any
39-
all_features: Any
40-
property_lexical_handler: Any
41-
property_declaration_handler: Any
42-
property_dom_node: Any
43-
property_xml_string: Any
44-
property_encoding: Any
45-
property_interning_dict: Any
46-
all_properties: Any
33+
feature_namespaces: str
34+
feature_namespace_prefixes: str
35+
feature_string_interning: str
36+
feature_validation: str
37+
feature_external_ges: str
38+
feature_external_pes: str
39+
all_features: list[str]
40+
property_lexical_handler: str
41+
property_declaration_handler: str
42+
property_dom_node: str
43+
property_xml_string: str
44+
property_encoding: str
45+
property_interning_dict: str
46+
all_properties: list[str]
47+
48+
if sys.version_info >= (3, 10):
49+
class LexicalHandler:
50+
def comment(self, content: str) -> object: ...
51+
def startDTD(self, name: str, public_id: str | None, system_id: str | None) -> object: ...
52+
def endDTD(self) -> object: ...
53+
def startCDATA(self) -> object: ...
54+
def endCDATA(self) -> object: ...

tests/stubtest_allowlists/py310.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,8 @@ multiprocessing.managers.SharedMemoryServer.public
9494
multiprocessing.managers.SharedMemoryServer.release_segment
9595
multiprocessing.managers.SharedMemoryServer.shutdown
9696
multiprocessing.managers.SharedMemoryServer.track_segment
97-
pyexpat.XMLParserType.SkippedEntityHandler
98-
pyexpat.XMLParserType.intern
9997
typing._SpecialForm.__call__
10098
unicodedata.UCD.is_normalized
101-
xml.parsers.expat.XMLParserType.SkippedEntityHandler
102-
xml.parsers.expat.XMLParserType.intern
103-
xml.sax.handler.LexicalHandler
10499

105100
# ==========
106101
# Related to positional-only arguments

tests/stubtest_allowlists/py311.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ platform.uname_result.processor
7878
pydoc.HTMLDoc.heading
7979
pydoc.HTMLDoc.multicolumn
8080
pydoc.HTMLDoc.section
81-
pyexpat.XMLParserType.SkippedEntityHandler
82-
pyexpat.XMLParserType.intern
83-
pyexpat.errors.XML_ERROR_AMPLIFICATION_LIMIT_BREACH
84-
pyexpat.errors.XML_ERROR_INVALID_ARGUMENT
85-
pyexpat.errors.XML_ERROR_NO_BUFFER
86-
pyexpat.errors.XML_ERROR_RESERVED_NAMESPACE_URI
87-
pyexpat.errors.XML_ERROR_RESERVED_PREFIX_XML
88-
pyexpat.errors.XML_ERROR_RESERVED_PREFIX_XMLNS
8981
queue.SimpleQueue.__init__
9082
shutil.rmtree
9183
socketserver.UDPServer.allow_reuse_port
@@ -117,15 +109,6 @@ unittest.doModuleCleanups
117109
urllib.request.FancyURLopener.http_error_308
118110
urllib.request.HTTPRedirectHandler.http_error_308
119111
weakref.WeakValueDictionary.update
120-
xml.parsers.expat.XMLParserType.SkippedEntityHandler
121-
xml.parsers.expat.XMLParserType.intern
122-
xml.parsers.expat.errors.XML_ERROR_AMPLIFICATION_LIMIT_BREACH
123-
xml.parsers.expat.errors.XML_ERROR_INVALID_ARGUMENT
124-
xml.parsers.expat.errors.XML_ERROR_NO_BUFFER
125-
xml.parsers.expat.errors.XML_ERROR_RESERVED_NAMESPACE_URI
126-
xml.parsers.expat.errors.XML_ERROR_RESERVED_PREFIX_XML
127-
xml.parsers.expat.errors.XML_ERROR_RESERVED_PREFIX_XMLNS
128-
xml.sax.handler.LexicalHandler
129112
xmlrpc.server.SimpleXMLRPCRequestHandler.rpc_paths
130113
zipfile.Path.stem
131114
zipfile.Path.suffix

tests/stubtest_allowlists/py36.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,6 @@ sqlite3.dbapi2.Binary.__iter__ # C type that implements __getitem__
177177
sqlite3.dbapi2.Binary.cast # inspect.signature is incorrect about shape being kw-only
178178
sqlite3.Binary.__iter__ # C type that implements __getitem__
179179
sqlite3.Binary.cast # inspect.signature is incorrect about shape being kw-only
180+
181+
pyexpat.XMLParserType.intern # does exist but stubtest can't see it (https://github.com/python/cpython/blob/3.7/Modules/pyexpat.c#L1322)
182+
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)

tests/stubtest_allowlists/py37.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ queue.SimpleQueue.__init__
170170

171171
pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args
172172
xml.parsers.expat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args
173+
pyexpat.XMLParserType.intern # does exist but stubtest can't see it (https://github.com/python/cpython/blob/3.7/Modules/pyexpat.c#L1322)
174+
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)
173175

174176
# White lies around defaults
175177
dataclasses.field

tests/stubtest_allowlists/py38.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ multiprocessing.managers.SharedMemoryServer.shutdown
129129
multiprocessing.managers.SharedMemoryServer.track_segment
130130
plistlib.Data.asBase64
131131
plistlib.Data.fromBase64
132-
pyexpat.XMLParserType.SkippedEntityHandler
133-
pyexpat.XMLParserType.intern
134132
stringprep.unicodedata # re-exported from unicodedata
135133
tempfile.SpooledTemporaryFile.softspace
136134
tkinter.Tk.split
@@ -153,8 +151,6 @@ tkinter.simpledialog.wantobjects
153151
tkinter.tix.wantobjects
154152
typing._SpecialForm.__call__
155153
unicodedata.UCD.is_normalized
156-
xml.parsers.expat.XMLParserType.SkippedEntityHandler
157-
xml.parsers.expat.XMLParserType.intern
158154

159155
# ==========
160156
# Allowlist entries that cannot or should not be fixed

tests/stubtest_allowlists/py39.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,11 @@ multiprocessing.managers.SharedMemoryServer.public
132132
multiprocessing.managers.SharedMemoryServer.release_segment
133133
multiprocessing.managers.SharedMemoryServer.shutdown
134134
multiprocessing.managers.SharedMemoryServer.track_segment
135-
pyexpat.XMLParserType.SkippedEntityHandler
136-
pyexpat.XMLParserType.intern
137135
stringprep.unicodedata # re-exported from unicodedata
138136
types.GenericAlias.__mro_entries__
139137
typing._SpecialForm.__call__
140138
typing._SpecialForm.__mro_entries__
141139
unicodedata.UCD.is_normalized
142-
xml.parsers.expat.XMLParserType.SkippedEntityHandler
143-
xml.parsers.expat.XMLParserType.intern
144140

145141
# SpooledTemporaryFile implements IO except these methods before Python 3.11
146142
# See also https://github.com/python/typeshed/pull/2452#issuecomment-420657918

0 commit comments

Comments
 (0)