bpo-34941: Fix searching Element subclasses. by serhiy-storchaka · Pull Request #9766 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation9 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

serhiy-storchaka

Methods find(), findtext() and findall() of xml.etree.ElementTree.Element
were not able to find chldren which are instances of Element subclasses.

https://bugs.python.org/issue34941

@serhiy-storchaka

Methods find(), findtext() and findall() of xml.etree.ElementTree.Element were not able to find chldren which are instances of Element subclasses.

@jackjansen

Neat find, thanks! One remark: should there be a note in the documentation (TreeBuilder section) that the element instance returned by the element_factory should be an instance of (a subclass of) Element?

@serhiy-storchaka

I am unsure. Some parts of the module requires Element subclasses and raise an error otherwise (e.g. append() ad iter()). Others support duck-typing (like slice assignment and serializing). You have found that some operations work only with exact Elements and silently ignore types. I think we need more changes in master, but I'm unsure what should these changes be: restrict children be instances of Element subclasses or add duck typing support everywhere.

See also bpo-28234.

@scoder

@miss-islington

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6, 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request

Oct 14, 2018

@serhiy-storchaka @miss-islington

Methods find(), findtext() and findall() of xml.etree.ElementTree.Element were not able to find chldren which are instances of Element subclasses. (cherry picked from commit b11c566)

Co-authored-by: Serhiy Storchaka storchaka@gmail.com

@bedevere-bot

@miss-islington

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker b11c5667f99c4f0018e3394c4d07c519d835671a 3.6

@miss-islington

Sorry, @serhiy-storchaka, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker b11c5667f99c4f0018e3394c4d07c519d835671a 2.7

@serhiy-storchaka

In 2.7 cElementTree.Element is not subclassable.

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request

Oct 14, 2018

@serhiy-storchaka

Methods find(), findtext() and findall() of xml.etree.ElementTree.Element were not able to find chldren which are instances of Element subclasses.. (cherry picked from commit b11c566)

Co-authored-by: Serhiy Storchaka storchaka@gmail.com

@bedevere-bot

miss-islington added a commit that referenced this pull request

Oct 14, 2018

@miss-islington @serhiy-storchaka

Methods find(), findtext() and findall() of xml.etree.ElementTree.Element were not able to find chldren which are instances of Element subclasses. (cherry picked from commit b11c566)

Co-authored-by: Serhiy Storchaka storchaka@gmail.com

serhiy-storchaka added a commit that referenced this pull request

Oct 14, 2018

@serhiy-storchaka

Methods find(), findtext() and findall() of xml.etree.ElementTree.Element were not able to find chldren which are instances of Element subclasses. (cherry picked from commit b11c566)

Labels

type-bug

An unexpected behavior, bug, or error