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 locale test failing on Python 3.7 due to forced UTF-8 mode being used in the test #7412

Merged
merged 1 commit into from Mar 21, 2019

Conversation

Projects
None yet
2 participants
@Eric-Arellano
Copy link
Contributor

commented Mar 21, 2019

Problem

Python 3.7 may be optionally ran in -x utf8 mode, meaning it runs Python using UTF-8 for everything, regardless of what the local locale is. See https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUTF8.

Because this defaults to being on in POSIX environments, in CI and locally our Pants subprocess was running with this value during the test test_invalid_locale, so our override of LC_ALL would have no actual impact. So, the test was not failing like it should have with Python 3.7.

Solution

Set the environment variable PYTHONUTF8 to 0 during this test to ensure the test does not run in forced UTF-8 mode.

Result

PY=python3.7 ./pants test tests/python/pants_test/bin: -- --verbose -k test_invalid_locale now passes.

This has no impact when being ran with Python 2.7 or Python 3.6, as Python will simply ignore that env var.

@Eric-Arellano Eric-Arellano requested review from stuhood and illicitonion Mar 21, 2019

@Eric-Arellano Eric-Arellano changed the title Fix locale test failing on Python 3.7 due to forced UTF-8 mode Fix locale test failing on Python 3.7 due to forced UTF-8 mode being used in the test Mar 21, 2019

@stuhood
Copy link
Member

left a comment

Because this defaults to being on in POSIX environments

Hallelujah!

@Eric-Arellano Eric-Arellano merged commit 6a66fdc into pantsbuild:master Mar 21, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:locale-test-py37 branch Mar 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.