-
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
[DO NOT MERGE] PR for testing windows encoding problems #1305
Conversation
Thanks for filing this PR to test things out. As I predicted, the CI on Windows failed, even though your commit was trivial. This:
fails with:
Looks like the default encoding for the console is CP1252, and not UTF-8. @hawkowl posted a good writeup of this here: https://twistedmatrix.com/pipermail/twisted-python/2020-June/065140.html I need to figure out a way to force the Azure Pipeline's Window console to be UTF-8. I'm not sure how to do that. |
The workarounds in the mail post (PYTHONIOENCODING and PYTHONUTF8) in the environment might do it.
…On Sun, 21 Jun 2020, at 17:49, Craig Rodrigues wrote:
Thanks for filing this PR to test things out. As I predicted, the CI on
Windows failed, even though your commit was trivial.
The first thing I notice is this:
https://dev.azure.com/twistedmatrix/twisted/_build/results?buildId=1970&view=logs&j=7f8b683a-20ec-5925-1eb0-0f9b67db6dcc&t=75248844-3620-5e60-359d-192232fba6b9
This:
`python -c "import os; print(os.environ)"`
fails with:
`2020-06-21T07:24:15.5571943Z Traceback (most recent call last):
2020-06-21T07:24:15.5580812Z File "<string>", line 1, in <module>
2020-06-21T07:24:15.5581991Z File
"C:\hostedtoolcache\windows\Python\3.6.8\x64\lib\encodings\cp1252.py",
line 19, in encode
2020-06-21T07:24:15.5583012Z return
codecs.charmap_encode(input,self.errors,encoding_table)[0]
2020-06-21T07:24:15.5584308Z UnicodeEncodeError: 'charmap' codec can't
encode character '\u0142' in position 2585: character maps to
<undefined>
2020-06-21T07:24:15.6292586Z 64
`
Looks like the default encoding for the console is CP1252, and not
UTF-8.
@hawkowl <https://github.com/hawkowl> posted a good writeup of this
here:
https://twistedmatrix.com/pipermail/twisted-python/2020-June/065140.html
I need to figure out a way to force the Azure Pipeline's Window console
to be UTF-8. I'm not sure how to do that.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1305 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZHMXGDJ75QII2LONDXZYTRXW3RXANCNFSM4ODXOYOQ>.
|
@hawkowl yes I think you are right. On the Azure pipeline side, the docs for configuring an environment variable is here: and on the Python side, the docs for those variables is here: https://docs.python.org/3/using/cmdline.html#envvar-PYTHONIOENCODING So if we can set the right value in the Azure pipeline yaml, we might be able to get this to work. |
We might need to |
6e7d817
to
b41a613
Compare
@hawkowl so I set PYTHONUTF8=1 in the azure yaml for windows, and I got the Python 3.7 and 3.8 builds to work. Looks like PYTHONUTF8 is only on Python 3.7+ I see an environment variable is getting set:
This confirm's my suspicion that Michał's non-ASCII name was getting exported as an environment variable somehow on the Windows build. |
@hawkowl do you know what the correct incantation of PYTHONIOENCODING is for Python 3.5 and 3.6, but won't interfere with the PYTHONUTF8 variable on Python 3.7+? |
PYTHONIOENCODING=utf-8:surrogateescape should do what you want. That's what UTF-8 mode enables, anyway.
…On Sun, 21 Jun 2020, at 20:08, Craig Rodrigues wrote:
@hawkowl <https://github.com/hawkowl> do you know what the correct
incantation of PYTHONIOENCODING is for Python 3.5 and 3.6, but won't
interfere with the PYTHONUTF8 variable on Python 3.7+?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1305 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZHMXCBA3OMPZGLSS3LN5DRXXLZTANCNFSM4ODXOYOQ>.
|
@hawkowl OK, I managed to set However on Python 3.5 and 3.6 some tests are failing:
In twisted/internet/base.py there is a function It looks like on Python 3.5 and 3.6, setting My recommendation is to nuke the This was added 12 years ago, and is a leftover from Python 2. In Python 3, os.environ is unicode on all platforms. |
3d410c6
to
3962f6a
Compare
So I deleted _checkProcessArgs() and one accompanying test, and managed to get all the tests to pass on all platforms, with this environment variable set:
@hawkowl I can submit a separate PR to eliminate |
e2db28e
to
af4d5ab
Compare
I'm closing this PR as it appears to have been superseded by #1302. If I'm mistaken please feel free to re-open. Thank you all! |
Also, remove an extraneous comment about Python 2, since the minimum Python version that Twisted supports is Python 3.5
#1302 is not merged yet. We are leaving this PR open, to test when someone with non-ASCII characters in their name, specifically Michał Górny, files a PR. |
on Windows Set PYTHONIOENCODING variable to utf8 for Python 3.5, 3.6
Inspired by Michał Górny
af4d5ab
to
85069b5
Compare
Followup for #1278 (comment)
CC @rodrigc