Skip to content

Commit

Permalink
Suggest use of "hasattr" with checking for 3.13 Expat API availability
Browse files Browse the repository at this point in the history
  • Loading branch information
hartwork committed Mar 3, 2024
1 parent 4d3ee77 commit 28b1c91
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Doc/library/pyexpat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ XMLParser Objects
Calling ``SetReparseDeferralEnabled(True)`` allows re-enabling reparse
deferral.

Note that :meth:`SetReparseDeferralEnabled` has been backported to prior
releases of CPython, so it is recommended to check for availability of
:meth:`SetReparseDeferralEnabled` using :func:`hasattr`
(rather than inspecting :const:`!pyexpat.version_info`),
at runtime.

.. versionadded:: 3.13

.. method:: xmlparser.GetReparseDeferralEnabled()
Expand Down
12 changes: 12 additions & 0 deletions Doc/library/xml.etree.elementtree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,12 @@ XMLParser Objects
Disabling reparse deferral has security consequences; please see
:meth:`xml.parsers.expat.xmlparser.SetReparseDeferralEnabled` for details.

Note that :meth:`flush` has been backported to prior releases of CPython,
so it is recommended to check for availability of :meth:`flush`
using :func:`hasattr`
(rather than inspecting :const:`!pyexpat.version_info`),
at runtime.

.. versionadded:: 3.13


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

Note that :meth:`flush` has been backported to prior releases of CPython,
so it is recommended to check for availability of :meth:`flush`
using :func:`hasattr`
(rather than inspecting :const:`!pyexpat.version_info`),
at runtime.

.. versionadded:: 3.13

.. method:: close()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Suggest use of :func:`hasattr` when checking for availability of Expat reparse
deferral security API.

0 comments on commit 28b1c91

Please sign in to comment.