GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing github.com — gh-83122: Deprecate testing element truth values in `ElementTree` by jacobtylerwalls · Pull Request #31149 · python/cpython Conversation
|
|
That's a fair point. On the bug report people were supportive of changing the behavior, but I don't know that it's ever actually going to happen. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Let’s find out first. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
If the warning was only shown by the Python version, very few people have seen it, right, because (I presume) the C version is always used if it can be imported. I'm guessing that the idea is that nodes will always be truthy, so you can use |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Forgive me if this is stating the obvious, but as I see the status quo, users are tempted to write
I might be misunderstanding you, but since nodes are not always truthy, I'm hoping for ElementTree to discourage this usage.
The applications that need to change will be ones that desired
Right. Of course if the ultimate resolution here is a warning rather than an exception, we could just change |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Ah, I didn't put that very well. Of course applications will have to deal with the warning proposed in the issue (and in the python implementation). I meant something like, applications "that might find this change unwelcome". |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
My understanding is that the warning put in the Python code (many, many releases ago?) was a FutureWarning because the plan of record at the time was to change the behavior, after a few releases of issuing warnings. (The error message says so: But since the warning is not printed in reality, there may also be code that has used the falsity of child-less nodes as a feature -- after all it was put in intentionally as a feature (long, long ago). Your experience of being bitten by this explains why it was a bad feature. It is not necessarily the case that code using I dislike warnings that live forever -- they have a place, but I don't have to like them, and if we're putting in a FutureWarning we promise to eventually change the behavior. So we need to have a think about that. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I posted on the issue to make sure we gather consensus on the right way forward here. Until we do that I'm unassigning myself from this PR. Sorry for getting your hopes up @jacobtylerwalls! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ElementTreeElementTree
|
Lets change the warning in the existing code and the new equivalent added to the C code to DeprecationWarning. FutureWarning was never intended to be used for this purpose. If we go forward with this, it'll become a behavior change in >= 3.14. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ElementTreeElementTree
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I have made the requested changes; please review again |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! @JelleZijlstra, @gpshead: please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
thanks! I'm so glad to see this long documented as a "bad idea" API wart on the way towards being cleaned up! :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (self->extra ? self->extra->length : 0) { | ||
| return 1; | ||
| } | ||
| return 0; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It could be simply
return self->extra && self->extra->length;
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
xml.etree.ElementTree.Element inconsistent warning for bool
There was an error while loading. Please reload this page.