Skip to content

Commit 660a1a1

Browse files
committed
address review
1 parent e7e0a7d commit 660a1a1

File tree

3 files changed

+37
-53
lines changed

3 files changed

+37
-53
lines changed

Doc/c-api/expat.rst

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,18 @@ the module state:
1818
if (capi == NULL) {
1919
goto error;
2020
}
21-
if (!PyExpat_CheckCompatibility(capi)) {
21+
if (!(
22+
strcmp(capi->magic, PyExpat_CAPI_MAGIC) == 0
23+
&& (size_t)capi->size >= sizeof(struct PyExpat_CAPI)
24+
&& capi->MAJOR_VERSION == XML_MAJOR_VERSION
25+
&& capi->MINOR_VERSION == XML_MINOR_VERSION
26+
&& capi->MICRO_VERSION == XML_MICRO_VERSION
27+
)) {
2228
PyErr_SetString(PyExc_ImportError, "pyexpat version is incompatible");
2329
goto error;
2430
}
2531
2632
27-
.. c:function:: int PyExpat_CheckCompatibility(struct PyExpat_CAPI *api)
28-
29-
Return ``1`` if *api* is compatible with the linked Expat library,
30-
and ``0`` otherwise. This function never sets a Python exception.
31-
32-
*api* must not be ``NULL``.
33-
34-
.. versionadded:: next
35-
36-
3733
.. c:macro:: PyExpat_CAPI_MAGIC
3834
3935
The Expat C API magic number.
@@ -148,23 +144,23 @@ the module state:
148144
XML_Parser parser,\
149145
unsigned long hash_salt)
150146
151-
Might be NULL for Expat versions prior to 2.1.0.
147+
Might be ``NULL`` for Expat versions prior to 2.1.0.
152148
153149
.. versionadded:: 3.4
154150
155151
.. c:member:: XML_Bool (*SetReparseDeferralEnabled)(\
156152
XML_Parser parser,\
157153
XML_Bool enabled)
158154
159-
Might be NULL for Expat versions prior to 2.6.0.
155+
Might be ``NULL`` for Expat versions prior to 2.6.0.
160156
161157
.. versionadded:: 3.8
162158
163159
.. c:member:: XML_Bool (*SetAllocTrackerActivationThreshold)(\
164160
XML_Parser parser,\
165161
unsigned long long activationThresholdBytes)
166162
167-
Might be NULL for Expat versions prior to 2.7.2.
163+
Might be ``NULL`` for Expat versions prior to 2.7.2.
168164
169165
.. uncomment this when the backport is done
170166
.. versionadded:: 3.10
@@ -173,7 +169,7 @@ the module state:
173169
XML_Parser parser,\
174170
float maxAmplificationFactor)
175171
176-
Might be NULL for Expat versions prior to 2.7.2.
172+
Might be ``NULL`` for Expat versions prior to 2.7.2.
177173
178174
.. uncomment this when the backport is done
179175
.. versionadded:: 3.10
@@ -182,7 +178,7 @@ the module state:
182178
XML_Parser parser,\
183179
unsigned long long activationThresholdBytes)
184180
185-
Might be NULL for Expat versions prior to 2.4.0.
181+
Might be ``NULL`` for Expat versions prior to 2.4.0.
186182
187183
.. uncomment this when the backport is done
188184
.. versionadded:: 3.10
@@ -191,7 +187,7 @@ the module state:
191187
XML_Parser parser,\
192188
float maxAmplificationFactor)
193189
194-
Might be NULL for Expat versions prior to 2.4.0.
190+
Might be ``NULL`` for Expat versions prior to 2.4.0.
195191
196192
.. uncomment this when the backport is done
197193
.. versionadded:: 3.10

Doc/conf.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -223,29 +223,6 @@
223223
('envvar', 'USERPROFILE'),
224224
]
225225

226-
# Vendored types
227-
nitpick_ignore += [
228-
("c:identifier", "XML_Bool"),
229-
("c:identifier", "XML_Char"),
230-
("c:identifier", "XML_CharacterDataHandler"),
231-
("c:identifier", "XML_CommentHandler"),
232-
("c:identifier", "XML_DefaultHandler"),
233-
("c:identifier", "XML_Encoding"),
234-
("c:identifier", "XML_EndElementHandler"),
235-
("c:identifier", "XML_EndNamespaceDeclHandler"),
236-
("c:identifier", "XML_Error"),
237-
("c:identifier", "XML_LChar"),
238-
("c:identifier", "XML_Memory_Handling_Suite"),
239-
("c:identifier", "XML_Parser"),
240-
("c:identifier", "XML_ProcessingInstructionHandler"),
241-
("c:identifier", "XML_Size"),
242-
("c:identifier", "XML_StartDoctypeDeclHandler"),
243-
("c:identifier", "XML_StartElementHandler"),
244-
("c:identifier", "XML_StartNamespaceDeclHandler"),
245-
("c:identifier", "XML_Status"),
246-
("c:identifier", "XML_UnknownEncodingHandler"),
247-
]
248-
249226
# Temporary undocumented names.
250227
# In future this list must be empty.
251228
nitpick_ignore += [
@@ -270,6 +247,30 @@
270247
nitpick_ignore.append(('c:identifier', name))
271248
del role, name
272249

250+
# Vendored identifiers. The list does not need to be empty.
251+
c_id_attributes = [
252+
# used in c-api/expat.rst
253+
"XML_Bool",
254+
"XML_Char",
255+
"XML_CharacterDataHandler",
256+
"XML_CommentHandler",
257+
"XML_DefaultHandler",
258+
"XML_Encoding",
259+
"XML_EndElementHandler",
260+
"XML_EndNamespaceDeclHandler",
261+
"XML_Error",
262+
"XML_LChar",
263+
"XML_Memory_Handling_Suite",
264+
"XML_Parser",
265+
"XML_ProcessingInstructionHandler",
266+
"XML_Size",
267+
"XML_StartDoctypeDeclHandler",
268+
"XML_StartElementHandler",
269+
"XML_StartNamespaceDeclHandler",
270+
"XML_Status",
271+
"XML_UnknownEncodingHandler",
272+
]
273+
273274
# Disable Docutils smartquotes for several translations
274275
smartquotes_excludes = {
275276
'languages': ['ja', 'fr', 'zh_TW', 'zh_CN'],

Include/pyexpat.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,3 @@ struct PyExpat_CAPI {
6363
XML_Parser parser, float maxAmplificationFactor);
6464
/* always add new stuff to the end! */
6565
};
66-
67-
static inline int
68-
PyExpat_CheckCompatibility(struct PyExpat_CAPI *api)
69-
{
70-
assert(api != NULL);
71-
return (
72-
strcmp(api->magic, PyExpat_CAPI_MAGIC) == 0
73-
&& (size_t)api->size >= sizeof(struct PyExpat_CAPI)
74-
&& api->MAJOR_VERSION == XML_MAJOR_VERSION
75-
&& api->MINOR_VERSION == XML_MINOR_VERSION
76-
&& api->MICRO_VERSION == XML_MICRO_VERSION
77-
);
78-
}

0 commit comments

Comments
 (0)