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
10581058 :meth: `~object.__getitem__ `, :meth: `~object.__setitem__ `,
10591059 :meth: `~object.__len__ `.
10601060
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.::
10641065
10651066 element = root.find('foo')
10661067
Original file line number Diff line number Diff line change @@ -1440,8 +1440,6 @@ and will be removed in Python 3.14.
14401440
14411441* :mod: `typing `: :class: `!typing.ByteString `
14421442
1443- * :mod: `xml.etree.ElementTree `: Testing the truth value of an :class: `xml.etree.ElementTree.Element `.
1444-
14451443* The ``__package__ `` and ``__cached__ `` attributes on module objects.
14461444
14471445* The :attr: `~codeobject.co_lnotab ` attribute of code objects.
@@ -1467,6 +1465,11 @@ although there is currently no date scheduled for their removal.
14671465
14681466* :class: `typing.Text ` (:gh: `92332 `)
14691467
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+
14701473* Currently Python accepts numeric literals immediately followed by keywords,
14711474 for example ``0in x ``, ``1or x ``, ``0if 1else 2 ``. It allows confusing
14721475 and ambiguous expressions like ``[0x1for x in y] `` (which can be
Original file line number Diff line number Diff line change @@ -1716,11 +1716,6 @@ Pending Removal in Python 3.14
17161716 public API.
17171717 (Contributed by Gregory P. Smith in :gh: `88168 `.)
17181718
1719- * :mod: `xml.etree.ElementTree `: Testing the truth value of an
1720- :class: `~xml.etree.ElementTree.Element ` is deprecated and will raise an
1721- exception in Python 3.14.
1722-
1723-
17241719Pending Removal in Python 3.15
17251720------------------------------
17261721
@@ -1925,6 +1920,11 @@ although there is currently no date scheduled for their removal.
19251920* :mod: `wsgiref `: ``SimpleHandler.stdout.write() `` should not do partial
19261921 writes.
19271922
1923+ * :mod: `xml.etree.ElementTree `: Testing the truth value of an
1924+ :class: `~xml.etree.ElementTree.Element ` is deprecated. In a future release it
1925+ it will always return ``True ``. Prefer explicit ``len(elem) `` or
1926+ ``elem is not None `` tests instead.
1927+
19281928* :meth: `zipimport.zipimporter.load_module ` is deprecated:
19291929 use :meth: `~zipimport.zipimporter.exec_module ` instead.
19301930
Original file line number Diff line number Diff line change @@ -4088,7 +4088,7 @@ class BoolTest(unittest.TestCase):
40884088 def test_warning (self ):
40894089 e = ET .fromstring ('<a style="new"></a>' )
40904090 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 "
40924092 r"future versions. "
40934093 r"Use specific 'len\(elem\)' or 'elem is not None' test instead." )
40944094 with self .assertWarnsRegex (DeprecationWarning , msg ):
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ def __len__(self):
201201
202202 def __bool__ (self ):
203203 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 "
205205 "future versions. "
206206 "Use specific 'len(elem)' or 'elem is not None' test instead." ,
207207 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_)
15021502{
15031503 ElementObject * self = (ElementObject * ) self_ ;
15041504 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 "
15061506 "in future versions. Use specific 'len(elem)' or "
15071507 "'elem is not None' test instead." ,
15081508 1 ) < 0 ) {
You can’t perform that action at this time.
0 commit comments