From 08d0d6d0f6eb5b88c30695da631faf19dca13f26 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Wed, 6 Mar 2024 20:08:25 +0100 Subject: [PATCH] gh-115398: Suggest use of `hasattr` with checking for 3.13 Expat API availability (GH-116278) Suggest use of "hasattr" with checking for 3.13 Expat API availability (cherry picked from commit 73807eb634315f70a464a18feaae33d9e065de09) --- Doc/library/pyexpat.rst | 5 +++++ Doc/library/xml.etree.elementtree.rst | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst index afbce469796caa..83815b75e92f3d 100644 --- a/Doc/library/pyexpat.rst +++ b/Doc/library/pyexpat.rst @@ -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.10.14 .. method:: xmlparser.GetReparseDeferralEnabled() diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst index f4a5eed11a912b..dbea33b8a0a64e 100644 --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -1385,6 +1385,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.10.14 @@ -1458,6 +1463,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.10.14 .. method:: close()