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

Fix AttributeError on Python 3.9 due to usage of removed API in xml #492

Merged
merged 2 commits into from
Dec 15, 2020

Conversation

kitchoi
Copy link
Contributor

@kitchoi kitchoi commented Dec 14, 2020

Closes #490

The first commit fixes errors that can be seen by running the test suite on Python 3.9.

The second commit makes similar changes, but those changes are not covered by tests.

On the changes that are not covered by test:
For enable.svg.document.addRectToDocument. I was trying to write a test that does something like this:

    def test_add_rect_to_document_with_clip_path(self):
       # create_svg_text is a function that adds the necessary XML declaration and <svg> root element
        svg_text = create_svg_text(
            '<rect x="11" y="11" clip-path="circle() view-box" />'
        )
        document = document.SVGDocument(etree.parse(StringIO(svg_text)).getroot(), renderer=KivaRenderer())

However it still does not reach the code path where I fixed the usage of ElementTree.
It seems that if 'clip-path' in node: is always false. Previously it was doing if 'clip-path' in node.keys() where keys() returns the XML attributes, but node was thought to be a dict during a migration from Python 2 to 3 (see #284). Upon fixing in node to in node.keys(), I run into another difficulty trying to open an SVG referenced by the clip-path assuming it was a local file. So I eventually gave up. I am happy to revert the second commit owing to the fact it is untested.

Copy link
Member

@jwiggins jwiggins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less broken than before... Let's iterate as needed here.

@kitchoi
Copy link
Contributor Author

kitchoi commented Dec 15, 2020

Thanks. I will open an issue for the clip-path code path being unreachable.

@kitchoi kitchoi merged commit 030f067 into master Dec 15, 2020
@kitchoi kitchoi deleted the fix-python3.9-elementtree-removed-usage branch December 15, 2020 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test errors on Python 3.9 due to deprecated usage of ElementTree.getiterator
2 participants