Skip to content

Commit 9f37778

Browse files
committed
Suggest use of "hasattr" with checking for 3.13 Expat API availability
1 parent 4d3ee77 commit 9f37778

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

Doc/library/pyexpat.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ XMLParser Objects
217217
Calling ``SetReparseDeferralEnabled(True)`` allows re-enabling reparse
218218
deferral.
219219

220+
Note that :meth:`SetReparseDeferralEnabled` has been backported to prior
221+
releases of CPython, so it is recommended to check for availability of
222+
:meth:`SetReparseDeferralEnabled` using :func:`hasattr`
223+
(rather than inspecting :const:`xml.parsers.expat.version_info`),
224+
at runtime.
225+
220226
.. versionadded:: 3.13
221227

222228
.. method:: xmlparser.GetReparseDeferralEnabled()

Doc/library/xml.etree.elementtree.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,12 @@ XMLParser Objects
14021402
Disabling reparse deferral has security consequences; please see
14031403
:meth:`xml.parsers.expat.xmlparser.SetReparseDeferralEnabled` for details.
14041404

1405+
Note that :meth:`flush` has been backported to prior releases of CPython,
1406+
so it is recommended to check for availability of :meth:`flush`
1407+
using :func:`hasattr`
1408+
(rather than inspecting :const:`xml.parsers.expat.version_info`),
1409+
at runtime.
1410+
14051411
.. versionadded:: 3.13
14061412

14071413

@@ -1475,6 +1481,12 @@ XMLPullParser Objects
14751481
Disabling reparse deferral has security consequences; please see
14761482
:meth:`xml.parsers.expat.xmlparser.SetReparseDeferralEnabled` for details.
14771483

1484+
Note that :meth:`flush` has been backported to prior releases of CPython,
1485+
so it is recommended to check for availability of :meth:`flush`
1486+
using :func:`hasattr`
1487+
(rather than inspecting :const:`xml.parsers.expat.version_info`),
1488+
at runtime.
1489+
14781490
.. versionadded:: 3.13
14791491

14801492
.. method:: close()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Suggest use of :func:`hasattr` when checking for availability of Expat reparse
2+
deferral security API.

0 commit comments

Comments
 (0)