-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Adjust deprecation warning re: testing truth value of xml.etree.ElementTree.Element
#119577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
AFAIK, the plan was to return True instead of raising an exception. |
In favor of raising an error: #83122 (comment) cc/ @gpshead who reviewed #31149, which changed FutureWarning to DeprecationWarning and documented that an exception would be raised. |
Raising an exception in |
We did document that it would raise an exception in the future. But I agree that that is unusual. Lets be conservative and delay the What that means is that we need a PR to update the docs and the DeprecationWarning error message to reflect the new plan. bool raising an exception does have valid uses: Such as when a class that is commonly mistaken for an actual boolean value in some API designs is easily misused in the wrong context. Element doesn't seem like one of those. |
We cannot just remove |
xml.etree.ElementTree.Element
raise an exceptionxml.etree.ElementTree.Element
… values in ElementTree
… values in ElementTree
New PR: #119762 |
…s 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.
… values in ElementTree (pythonGH-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. (cherry picked from commit 6b60652) Co-authored-by: Jacob Walls <[email protected]>
… values in ElementTree (pythonGH-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.
…h values in ElementTree (GH-119762) (GH-120189) 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. (cherry picked from commit 6b60652) Co-authored-by: Jacob Walls <[email protected]>
… values in ElementTree (pythonGH-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.
… values in ElementTree (pythonGH-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.
… values in ElementTree (pythonGH-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.
…h values in Element tree (GH-119762) (#120190) 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. Co-authored-by: Jacob Walls <[email protected]>
Triage: closing because the PR has been merged, please re-open if still needed. Thanks! |
DeprecationWarning: Testing an element's truth value will always return True in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. python/cpython#119577
Testing the truth value of an
ElementTree.Element
was deprecated in python 3.12 and scheduled for removal in 3.14. I have a patch ready.ElementTree
#31149Linked PRs
The text was updated successfully, but these errors were encountered: