File tree Expand file tree Collapse file tree 7 files changed +21
-13
lines changed Expand file tree Collapse file tree 7 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -1058,9 +1058,10 @@ Element Objects
1058
1058
:meth: `~object.__getitem__ `, :meth: `~object.__setitem__ `,
1059
1059
:meth: `~object.__len__ `.
1060
1060
1061
- Caution: Elements with no subelements will test as ``False ``. Testing the
1062
- truth value of an Element is deprecated and will raise an exception in
1063
- Python 3.14. Use specific ``len(elem) `` or ``elem is None `` test instead.::
1061
+ Caution: Elements with no subelements will test as ``False ``. In a future
1062
+ release of Python, all elements will test as ``True `` regardless of whether
1063
+ subelements exist. Instead, prefer explicit ``len(elem) `` or
1064
+ ``elem is not None `` tests.::
1064
1065
1065
1066
element = root.find('foo')
1066
1067
Original file line number Diff line number Diff line change @@ -1440,8 +1440,6 @@ and will be removed in Python 3.14.
1440
1440
1441
1441
* :mod: `typing `: :class: `!typing.ByteString `
1442
1442
1443
- * :mod: `xml.etree.ElementTree `: Testing the truth value of an :class: `xml.etree.ElementTree.Element `.
1444
-
1445
1443
* The ``__package__ `` and ``__cached__ `` attributes on module objects.
1446
1444
1447
1445
* The :attr: `~codeobject.co_lnotab ` attribute of code objects.
@@ -1467,6 +1465,11 @@ although there is currently no date scheduled for their removal.
1467
1465
1468
1466
* :class: `typing.Text ` (:gh: `92332 `)
1469
1467
1468
+ * :mod: `xml.etree.ElementTree `: Testing the truth value of an
1469
+ :class: `xml.etree.ElementTree.Element ` is deprecated. In a future release it
1470
+ will always return True. Prefer explicit ``len(elem) `` or
1471
+ ``elem is not None `` tests instead.
1472
+
1470
1473
* Currently Python accepts numeric literals immediately followed by keywords,
1471
1474
for example ``0in x ``, ``1or x ``, ``0if 1else 2 ``. It allows confusing
1472
1475
and ambiguous expressions like ``[0x1for x in y] `` (which can be
Original file line number Diff line number Diff line change @@ -1728,11 +1728,6 @@ Pending Removal in Python 3.14
1728
1728
public API.
1729
1729
(Contributed by Gregory P. Smith in :gh: `88168 `.)
1730
1730
1731
- * :mod: `xml.etree.ElementTree `: Testing the truth value of an
1732
- :class: `~xml.etree.ElementTree.Element ` is deprecated and will raise an
1733
- exception in Python 3.14.
1734
-
1735
-
1736
1731
Pending Removal in Python 3.15
1737
1732
------------------------------
1738
1733
@@ -1937,6 +1932,11 @@ although there is currently no date scheduled for their removal.
1937
1932
* :mod: `wsgiref `: ``SimpleHandler.stdout.write() `` should not do partial
1938
1933
writes.
1939
1934
1935
+ * :mod: `xml.etree.ElementTree `: Testing the truth value of an
1936
+ :class: `~xml.etree.ElementTree.Element ` is deprecated. In a future release it
1937
+ it will always return ``True ``. Prefer explicit ``len(elem) `` or
1938
+ ``elem is not None `` tests instead.
1939
+
1940
1940
* :meth: `zipimport.zipimporter.load_module ` is deprecated:
1941
1941
use :meth: `~zipimport.zipimporter.exec_module ` instead.
1942
1942
Original file line number Diff line number Diff line change @@ -4088,7 +4088,7 @@ class BoolTest(unittest.TestCase):
4088
4088
def test_warning (self ):
4089
4089
e = ET .fromstring ('<a style="new"></a>' )
4090
4090
msg = (
4091
- r"Testing an element's truth value will raise an exception in "
4091
+ r"Testing an element's truth value will always return True in "
4092
4092
r"future versions. "
4093
4093
r"Use specific 'len\(elem\)' or 'elem is not None' test instead." )
4094
4094
with self .assertWarnsRegex (DeprecationWarning , msg ):
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ def __len__(self):
201
201
202
202
def __bool__ (self ):
203
203
warnings .warn (
204
- "Testing an element's truth value will raise an exception in "
204
+ "Testing an element's truth value will always return True in "
205
205
"future versions. "
206
206
"Use specific 'len(elem)' or 'elem is not None' test instead." ,
207
207
DeprecationWarning , stacklevel = 2
Original file line number Diff line number Diff line change
1
+ The :exc: `DeprecationWarning ` emitted when testing the truth value of an
2
+ :class: `xml.etree.ElementTree.Element ` now describes unconditionally
3
+ returning ``True `` in a future version rather than raising an exception in
4
+ Python 3.14.
Original file line number Diff line number Diff line change @@ -1502,7 +1502,7 @@ element_bool(PyObject* self_)
1502
1502
{
1503
1503
ElementObject * self = (ElementObject * ) self_ ;
1504
1504
if (PyErr_WarnEx (PyExc_DeprecationWarning ,
1505
- "Testing an element's truth value will raise an exception "
1505
+ "Testing an element's truth value will always return True "
1506
1506
"in future versions. Use specific 'len(elem)' or "
1507
1507
"'elem is not None' test instead." ,
1508
1508
1 ) < 0 ) {
You can’t perform that action at this time.
0 commit comments