]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-83122: Deprecate testing element truth values in `ElementTree` (#31149)
authorJacob Walls <jacobtylerwalls@gmail.com>
Mon, 23 Jan 2023 01:16:48 +0000 (20:16 -0500)
committerGitHub <noreply@github.com>
Mon, 23 Jan 2023 01:16:48 +0000 (17:16 -0800)
commitd717be04dc7876696cb21ce7901bda0214c4b2e0
tree32f9d28061733ce7c115474b76d77ea14fb209c5
parent997073c28b2f8d199ff97759775208bc9a99b2b3
gh-83122: Deprecate testing element truth values in `ElementTree` (#31149)

When testing element truth values, emit a DeprecationWarning in all implementations.

This had emitted a FutureWarning in the rarely used python-only implementation since ~2.7 and has always been documented as a behavior not to rely on.

Matching an element in a tree search but having it test False can be unexpected. Raising the warning enables making the choice to finally raise an exception for this ambiguous behavior in the future.
Doc/library/xml.etree.elementtree.rst
Doc/whatsnew/3.12.rst
Lib/test/test_xml_etree.py
Lib/xml/etree/ElementTree.py
Misc/NEWS.d/next/Library/2022-02-05-12-01-58.bpo-38941.8IhvyG.rst [new file with mode: 0644]
Modules/_elementtree.c