Skip to content

Commit

Permalink
gh-115398: Suggest use of hasattr with checking for 3.13 Expat API …
Browse files Browse the repository at this point in the history
…availability (GH-116278)

Suggest use of "hasattr" with checking for 3.13 Expat API availability

(cherry picked from commit 73807eb)
  • Loading branch information
hartwork committed Mar 6, 2024
1 parent 66d991b commit 5573d60
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Doc/library/pyexpat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ XMLParser Objects
Calling ``SetReparseDeferralEnabled(True)`` allows re-enabling reparse
deferral.

Note that :meth:`SetReparseDeferralEnabled` has been backported to some
prior releases of CPython as a security fix. Check for availability of
:meth:`SetReparseDeferralEnabled` using :func:`hasattr` if used in code
running across a variety of Python versions.

.. versionadded:: 3.12.3

.. method:: xmlparser.GetReparseDeferralEnabled()
Expand Down
10 changes: 10 additions & 0 deletions Doc/library/xml.etree.elementtree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,11 @@ 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 some prior releases of
CPython as a security fix. Check for availability of :meth:`flush`
using :func:`hasattr` if used in code running across a variety of Python
versions.

.. versionadded:: 3.12.3


Expand Down Expand Up @@ -1470,6 +1475,11 @@ 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 some prior releases of
CPython as a security fix. Check for availability of :meth:`flush`
using :func:`hasattr` if used in code running across a variety of Python
versions.

.. versionadded:: 3.12.3

.. method:: close()
Expand Down

0 comments on commit 5573d60

Please sign in to comment.