summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2024-06-07 03:18:30 (GMT)
committerGitHub <noreply@github.com>2024-06-07 03:18:30 (GMT)
commit6b606522ca97488aad6fe2f193d4511e7a8f8334 (patch)
tree39a2f4ea67ddb62eb1ae01768cc20c6b60e2a41d /Doc
parent14e1506a6d7056c38fbbc0797268dcf783f91243 (diff)
downloadcpython-6b606522ca97488aad6fe2f193d4511e7a8f8334.zip
cpython-6b606522ca97488aad6fe2f193d4511e7a8f8334.tar.gz
cpython-6b606522ca97488aad6fe2f193d4511e7a8f8334.tar.bz2
gh-119577: Adjust DeprecationWarning when testing element truth values in ElementTree (GH-119762)
Adjust DeprecationWarning when testing element truth values in ElementTree, we're planning to go with the more natural True return rather than a disruptive harder to code around exception raise, and are deferring the behavior change for a few more releases.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/xml.etree.elementtree.rst7
-rw-r--r--Doc/whatsnew/3.12.rst7
-rw-r--r--Doc/whatsnew/3.13.rst10
3 files changed, 14 insertions, 10 deletions
diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst
index a6a9eb8..e591902 100644
--- a/Doc/library/xml.etree.elementtree.rst
+++ b/Doc/library/xml.etree.elementtree.rst
@@ -1058,9 +1058,10 @@ Element Objects
:meth:`~object.__getitem__`, :meth:`~object.__setitem__`,
:meth:`~object.__len__`.
- Caution: Elements with no subelements will test as ``False``. Testing the
- truth value of an Element is deprecated and will raise an exception in
- Python 3.14. Use specific ``len(elem)`` or ``elem is None`` test instead.::
+ Caution: Elements with no subelements will test as ``False``. In a future
+ release of Python, all elements will test as ``True`` regardless of whether
+ subelements exist. Instead, prefer explicit ``len(elem)`` or
+ ``elem is not None`` tests.::
element = root.find('foo')
diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst
index f99489f..28b28e9 100644
--- a/Doc/whatsnew/3.12.rst
+++ b/Doc/whatsnew/3.12.rst
@@ -1440,8 +1440,6 @@ and will be removed in Python 3.14.
* :mod:`typing`: :class:`!typing.ByteString`
-* :mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`xml.etree.ElementTree.Element`.
-
* The ``__package__`` and ``__cached__`` attributes on module objects.
* The :attr:`~codeobject.co_lnotab` attribute of code objects.
@@ -1467,6 +1465,11 @@ although there is currently no date scheduled for their removal.
* :class:`typing.Text` (:gh:`92332`)
+* :mod:`xml.etree.ElementTree`: Testing the truth value of an
+ :class:`xml.etree.ElementTree.Element` is deprecated. In a future release it
+ will always return True. Prefer explicit ``len(elem)`` or
+ ``elem is not None`` tests instead.
+
* Currently Python accepts numeric literals immediately followed by keywords,
for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing
and ambiguous expressions like ``[0x1for x in y]`` (which can be
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index a1d2a0d..81daaab 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -1728,11 +1728,6 @@ Pending Removal in Python 3.14
public API.
(Contributed by Gregory P. Smith in :gh:`88168`.)
-* :mod:`xml.etree.ElementTree`: Testing the truth value of an
- :class:`~xml.etree.ElementTree.Element` is deprecated and will raise an
- exception in Python 3.14.
-
-
Pending Removal in Python 3.15
------------------------------
@@ -1937,6 +1932,11 @@ although there is currently no date scheduled for their removal.
* :mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial
writes.
+* :mod:`xml.etree.ElementTree`: Testing the truth value of an
+ :class:`~xml.etree.ElementTree.Element` is deprecated. In a future release it
+ it will always return ``True``. Prefer explicit ``len(elem)`` or
+ ``elem is not None`` tests instead.
+
* :meth:`zipimport.zipimporter.load_module` is deprecated:
use :meth:`~zipimport.zipimporter.exec_module` instead.