-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
@mgorny As you are working on your PR's for Twisted, can you run:
in the top-level directory of your tree before pushing to GitHub? |
src/twisted/internet/base.py
Outdated
@@ -971,7 +971,7 @@ def argChecker(arg): | |||
""" | |||
if isinstance(arg, unicode): | |||
try: | |||
arg = arg.encode(defaultEncoding) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part looks OK.
There was a problem hiding this comment.
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.
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. |
Actually, I don't think there were any reports for files I've modified. |
@mgorny The linter failed on your branch here: https://travis-ci.com/github/twisted/twisted/jobs/341031233 You can confirm by running |
My commit does not touch this file. @hawkowl 's does. |
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.
…On Tue, 9 Jun 2020, at 17:22, Michał Górny wrote:
> @mgorny <https://github.com/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
<https://github.com/hawkowl> 's does.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1278 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZHMXEVXKZV5XPVGY56LCLRVXPL3ANCNFSM4NMEX2SA>.
|
No luck, then? |
I know that Azure Pipelines is passing in Unicode fine, it's just that older Python 3s (before the UTF-8 on Windows PEP) choke on outputting it because the default encoding goes to cp1252 :(
So, that means that we might just have to run the Twisted tests on Windows with -X utf8 or so, but then we're running the tests with a "non-standard" version/configuration of Python. But, since the default behaviour breaks for dumb reasons (accepting Unicode environment variables that it can't then output), perhaps running without -X utf8 or equiv on Windows should be deprecated/warned about as defective by design and unsupported (especially since Windows isn't DOS anymore, and all Linux/MacOS tests rely on proper Unicode support).
I'll raise this on the ML, since this may have other solutions (such as manually configuring the output in Python space, perhaps) that I haven't thought of.
As far as this/other PRs: I think that due to the issue being that Windows is extremely dumb, we can safely ignore the tests that fail on Windows on all your PRs as unrelated. I hope to get to reviewing these soon, just been caught up with starting a new job.
Sorry for the hassle, and thanks again for your contributions. 💜
…On Tue, 9 Jun 2020, at 17:34, Michał Górny wrote:
> 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?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1278 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZHMXGC73SKCWBI2PHUROTRVXQXJANCNFSM4NMEX2SA>.
|
There was a problem hiding this 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.
src/twisted/test/test_process.py
Outdated
@@ -483,7 +483,7 @@ class GetEnvironmentDictionary(UtilityProcessProtocol): | |||
and expose it to interested parties. | |||
""" | |||
programName = b"twisted.test.process_getenv" | |||
|
|||
There was a problem hiding this comment.
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 :).
azure-pipelines/run_test_steps.yml
Outdated
PYTHONUTF8: "1" | ||
PYTHONIOENCODING: "utf8:surrogateescape" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
3b1e2f2
to
e030503
Compare
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
e030503
to
de862b3
Compare
Also, remove an extraneous comment about Python 2, since the minimum Python version that Twisted supports is Python 3.5
de862b3
to
bbcb813
Compare
There was a problem hiding this 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.
@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. |
@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. |
Sure. I presume you'd need me to submit some boilerplate pull request to get my ID on it, correct? |
Fixed in |
@mgorny OK, no rush on this, but whenever you have time, can you do the following:
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! |
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:
review
to the keywords field in Trac, and putting a link to this PR in the comment; it shows up in https://twisted.reviews/ now.