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

Use xml.etree.ElementTree instead of deprecated cElementTree #1278

Closed
wants to merge 2 commits into from

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented May 27, 2020

The xml.etree.cElementTree is deprecated, and has been removed in Python
3.9. At the same time, xml.etree.ElementTree has already been using
cElementTree implicitly since Python 3.3. Update test_flatten to use
the latter to provide compatibility with newer Python versions.

Fixes: ticket:9834

Contributor Checklist:

Sorry, something went wrong.

@rodrigc
Copy link
Contributor

rodrigc commented Jun 8, 2020

@mgorny As you are working on your PR's for Twisted, can you run:

tox -e lint

in the top-level directory of your tree before pushing to GitHub?
This will identify some small style/whitespace errors in your PR which show up as errors
in the CI for Twisted.

@rodrigc
Copy link
Contributor

rodrigc commented Jun 9, 2020

@mgorny can you run tox -e lint in the top-level of your tree before pushing to GitHub, and take a pass at fixing any whitespace/style errors reported by the linter?

In your other PR, I fixed a few simple ones here: 686f20f

@@ -971,7 +971,7 @@ def argChecker(arg):
"""
if isinstance(arg, unicode):
try:
arg = arg.encode(defaultEncoding)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you put this in here for debugging some of the CI failures on Windows?

@@ -9,7 +9,7 @@
import sys
import traceback

from xml.etree.cElementTree import XML
Copy link
Contributor

Choose a reason for hiding this comment

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

This part looks OK.

Copy link
Member

Choose a reason for hiding this comment

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

This does look fine, and I wonder why it would provoke these Windows failures.

@mgorny
Copy link
Contributor Author

mgorny commented Jun 9, 2020

@mgorny As you are working on your PR's for Twisted, can you run:

tox -e lint

in the top-level directory of your tree before pushing to GitHub?
This will identify some small style/whitespace errors in your PR which show up as errors
in the CI for Twisted.

I did but I don't think it found anything in my changes. I wasn't sure if I'm supposed to make irrelevant style fixes in existing code.

@mgorny
Copy link
Contributor Author

mgorny commented Jun 9, 2020

Actually, I don't think there were any reports for files I've modified.

@rodrigc
Copy link
Contributor

rodrigc commented Jun 9, 2020

@mgorny The linter failed on your branch here: https://travis-ci.com/github/twisted/twisted/jobs/341031233

You can confirm by running tox -e lint

@mgorny
Copy link
Contributor Author

mgorny commented Jun 9, 2020

@mgorny The linter failed on your branch here: https://travis-ci.com/github/twisted/twisted/jobs/341031233

You can confirm by running tox -e lint

My commit does not touch this file. @hawkowl 's does.

@hawkowl
Copy link
Member

hawkowl commented Jun 9, 2020 via email

@mgorny
Copy link
Contributor Author

mgorny commented Jun 9, 2020

Yeah, sorry. That was me trying to debug Azure Pipelines breaking on your name so then it goes green :/ feel free to force push it back up to remove the commits.

No luck, then?

@hawkowl
Copy link
Member

hawkowl commented Jun 9, 2020 via email

Copy link
Member

@glyph glyph left a comment

Choose a reason for hiding this comment

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

Sadly we're still failing CI on this, and I don't think the tweak to fix this is a good idea. But also, are we just seeing these CI failures on trunk too?

If you could please back out the unrelated stuff, we'll separately try to address the build failure on trunk.

@@ -483,7 +483,7 @@ class GetEnvironmentDictionary(UtilityProcessProtocol):
and expose it to interested parties.
"""
programName = b"twisted.test.process_getenv"

Copy link
Member

Choose a reason for hiding this comment

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

This trailing whitespace is probably not necessary :).

Comment on lines 56 to 57
PYTHONUTF8: "1"
PYTHONIOENCODING: "utf8:surrogateescape"
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this was an attempt to fix the failing windows tests… which are still failing.

In general I am concerned about adding env vars like this to the test suite, since we might inadvertently introduce features into Twisted where it can't work without custom configuration on Windows, so we should remove this.

@@ -9,7 +9,7 @@
import sys
import traceback

from xml.etree.cElementTree import XML
Copy link
Member

Choose a reason for hiding this comment

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

This does look fine, and I wonder why it would provoke these Windows failures.

@mgorny mgorny force-pushed the 9834-mgorny-elementtree branch from 3b1e2f2 to e030503 Compare June 18, 2020 06:17
@mgorny
Copy link
Contributor Author

mgorny commented Jun 18, 2020

Ok, reverted to my original change.

The xml.etree.cElementTree is deprecated, and has been removed in Python
3.9.  At the same time, xml.etree.ElementTree has already been using
cElementTree implicitly since Python 3.3.  Update test_flatten to use
the latter to provide compatibility with newer Python versions.

Fixes: ticket:9834
Also, remove an extraneous comment about Python 2, since the minimum
Python version that Twisted supports is Python 3.5
Copy link
Contributor

@rodrigc rodrigc left a comment

Choose a reason for hiding this comment

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

The original change for using xml.etree.ElementTree is OK.

The CI errors have nothing to do with this change.

@rodrigc
Copy link
Contributor

rodrigc commented Jun 20, 2020

@mgorny it looks like the CI errors have to do with the fact that your GitHub ID has non-ASCII characters in its name, because I cannot reproduce the problem on Azure when I submit the same code change from my branch under my GitHub ID.

@rodrigc
Copy link
Contributor

rodrigc commented Jun 20, 2020

@mgorny This problem is actually kind of interesting. :)

I will get your Python 3.9 changes into the tree today, but if you are cool with it, I'd like to collaborate with you a bit and try to fix this Unicode thing on the Twisted side.
We should not block people from submitting fixes to Twisted if they have non-ASCII characters in their name!! This is 2020!

@mgorny
Copy link
Contributor Author

mgorny commented Jun 20, 2020

Sure. I presume you'd need me to submit some boilerplate pull request to get my ID on it, correct?

@rodrigc
Copy link
Contributor

rodrigc commented Jun 20, 2020

Fixed in

@rodrigc rodrigc closed this Jun 20, 2020
@rodrigc
Copy link
Contributor

rodrigc commented Jun 20, 2020

@mgorny OK, no rush on this, but whenever you have time, can you do the following:

  1. Take my branch 9858-rodrigc-mgorny-unicode, make a new branch from that.
  2. Make a small but trivial change to some .py file in the Twisted tree. Try to do the minimal change, so as to not break any of the linters (we don't want to have linter failures adding to the confusion).
  3. Make a new PR with your new branch using your mgorny GitHub ID.

I bet you that the CI will fail on Windows for that....

@hawkowl did a really good write-up about the problem of UTF-8 vs. CP1252 here: https://twistedmatrix.com/pipermail/twisted-python/2020-June/065140.html

It took me a while to connect the dots that your GitHub ID was triggering these failures!

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.

None yet

4 participants