Skip to content
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

gh-91447: Fix findtext to only give an empty string on None #91486

Merged
merged 3 commits into from Aug 1, 2022

Conversation

eugenetriguba
Copy link
Contributor

@eugenetriguba eugenetriguba commented Apr 12, 2022

The API documentation for findtext states that this function gives back an empty string on "no text content." With the previous implementation, this would give back a empty string even on text content values such as 0 or False. This patch attempts to resolve that by only giving back an empty string if the text attribute is set to None. Resolves #91447.

Automerge-Triggered-By: GH:gvanrossum

The API documentation for it states that this function
gives back an empty string on "no text content." With
the previous implementation, this would give back an
emtpy string even on text content values such as 0 or
False. This attempts to resolve that by only giving
back an empty string if the text attribute is set to
None.
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Please remove redundant empty lines.

@eugenetriguba
Copy link
Contributor Author

eugenetriguba commented Jul 22, 2022

@serhiy-storchaka This is in reference to line 419 and line 422?

@eugenetriguba
Copy link
Contributor Author

eugenetriguba commented Jul 22, 2022

Are you also referring to line 2742 and line 2751?

Copy link
Member

@gvanrossum gvanrossum left a comment

After considering it more I think this is fine. I don't think we should merge into 3.11 though, we're too close to RC1.

Lib/test/test_xml_etree.py Outdated Show resolved Hide resolved
Lib/test/test_xml_etree.py Outdated Show resolved Hide resolved
Lib/xml/etree/ElementPath.py Outdated Show resolved Hide resolved
@gvanrossum gvanrossum added the 🤖 automerge PR will be merged once it's been approved and all CI passed label Aug 1, 2022
@miss-islington
Copy link
Contributor

miss-islington commented Aug 1, 2022

Status check is done, and it's a success .

@miss-islington miss-islington merged commit a95e60d into python:main Aug 1, 2022
14 checks passed
@gvanrossum
Copy link
Member

gvanrossum commented Aug 1, 2022

@pablogsal Do you recommend backporting this to 3.11? It's been like that forever, so it doesn't strike me as urgent. If not to 3.11, would it go into 3.11.1 or stay in 3.12?

@pablogsal
Copy link
Member

pablogsal commented Aug 1, 2022

@pablogsal Do you recommend backporting this to 3.11?

Thanks for checking with me! Yeah, I think is ok to backport to 3.11 given that is a small fix that's fixing an existing bug. But please, let's do it before rc1 :)

@miss-islington
Copy link
Contributor

miss-islington commented Aug 1, 2022

Thanks @eugenetriguba for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒🤖

@bedevere-bot
Copy link

bedevere-bot commented Aug 1, 2022

GH-95543 is a backport of this pull request to the 3.11 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 1, 2022
…thonGH-91486)

The API documentation for [findtext](https://docs.python.org/3/library/xml.etree.elementtree.htmlGH-xml.etree.ElementTree.Element.findtext) states that this function gives back an empty string on "no text content." With the previous implementation, this would give back a empty string even on text content values such as 0 or False. This patch attempts to resolve that by only giving back an empty string if the text attribute is set to `None`. Resolves pythonGH-91447.

Automerge-Triggered-By: GH:gvanrossum
(cherry picked from commit a95e60d)

Co-authored-by: Eugene Triguba <eugenetriguba@gmail.com>
miss-islington added a commit that referenced this pull request Aug 1, 2022
The API documentation for [findtext](https://docs.python.org/3/library/xml.etree.elementtree.htmlGH-xml.etree.ElementTree.Element.findtext) states that this function gives back an empty string on "no text content." With the previous implementation, this would give back a empty string even on text content values such as 0 or False. This patch attempts to resolve that by only giving back an empty string if the text attribute is set to `None`. Resolves GH-91447.

Automerge-Triggered-By: GH:gvanrossum
(cherry picked from commit a95e60d)

Co-authored-by: Eugene Triguba <eugenetriguba@gmail.com>
@eugenetriguba eugenetriguba deleted the fix/91447-xml-findtext branch Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 🤖 automerge PR will be merged once it's been approved and all CI passed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

findtext returns empty string on integer zero value
6 participants