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
gh-95027: Fix regrtest stdout encoding on Windows #98492
Conversation
I failed to write a test reproducing the bug in test_regrtest, since test_regrtest runs the test suite with stdout being a pipe, which works around the bug :-( I tried to add this test: def test_nonascii(self):
character = chr(0xe9)
line = f"nonascii: {character}"
encoding = locale.getencoding()
try:
line.encode(encoding)
except EncodingError:
self.skipTest(f"fail to encode character U+00E9 "
f"to locale encoding {encoding}")
code = textwrap.dedent(f"""
import unittest
class Tests(unittest.TestCase):
def test_nonascii(self):
line = {line!a}
print(line)
""")
testname = self.create_test(code=code)
# sequential execution: may use the terminal
output = self.run_tests(testname)
self.check_executed_tests(output, [testname])
self.assertIn(line, output)
# parallel execution: stdout is a temporary file
output = self.run_tests("-j1", testname)
self.check_executed_tests(output, [testname])
self.assertIn(line, output) |
On Windows, when the Python test suite is run with the -jN option, the ANSI code page is now used as the encoding for the stdout temporary file, rather than using UTF-8 which can lead to decoding errors.
Thanks @vstinner for the PR |
On Windows, when the Python test suite is run with the -jN option, the ANSI code page is now used as the encoding for the stdout temporary file, rather than using UTF-8 which can lead to decoding errors. (cherry picked from commit ec1f6f5) Co-authored-by: Victor Stinner <vstinner@python.org>
I would prefer a formal review, but I merged my PR just to unblock the 3.11.0 final release (scheduled next Monday). Maybe if something can be enhanced, it can be done later. IMO this fix is better than the current situation. In short, it just restores the old behavior: encodings used before 199ba23 |
Thanks @vstinner for the PR |
On Windows, when the Python test suite is run with the -jN option, the ANSI code page is now used as the encoding for the stdout temporary file, rather than using UTF-8 which can lead to decoding errors. (cherry picked from commit ec1f6f5) Co-authored-by: Victor Stinner <vstinner@python.org>
3.11 backport: #98521 (review) |
On Windows, when the Python test suite is run with the -jN option, the ANSI code page is now used as the encoding for the stdout temporary file, rather than using UTF-8 which can lead to decoding errors. (cherry picked from commit ec1f6f5) Co-authored-by: Victor Stinner <vstinner@python.org>
On Windows, when the Python test suite is run with the -jN option, the ANSI code page is now used as the encoding for the stdout temporary file, rather than using UTF-8 which can lead to decoding errors. (cherry picked from commit ec1f6f5) Co-authored-by: Victor Stinner <vstinner@python.org>
On Windows, when the Python test suite is run with the -jN option, the ANSI code page is now used as the encoding for the stdout temporary file, rather than using UTF-8 which can lead to decoding errors. (cherry picked from commit ec1f6f5) Co-authored-by: Victor Stinner <vstinner@python.org>
On Windows, when the Python test suite is run with the -jN option, the ANSI code page is now used as the encoding for the stdout temporary file, rather than using UTF-8 which can lead to decoding errors.