Skip to content

Conversation

@iritkatriel
Copy link
Member

@iritkatrieliritkatriel commented Jan 29, 2022

I was able to reproduce the failure on a Mac, and this change fixes it.

https://bugs.python.org/issue44031

# by OS Windows.
out=out.decode('ascii')
err=err.decode('ascii')
out=out.decode('utf-8')
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to use os.fsdecode() instead. subprocess uses the locale encoding, it can be different than UTF-8. Moreover, fsdecode() uses the surrogateescape error handler for undecodable bytes.

@vstinner
Copy link
Member

I confirm that this PR fix https://bugs.python.org/issue44031

Without this PR, the test fails if the Python directory contains Загрузки:

$ pwd /home/vstinner/python/Загрузки $ ./python -m test -v test_tabnanny (...) ERROR: test_command_usage (test.test_tabnanny.TestCommandLine) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/vstinner/python/Загрузки/Lib/test/test_tabnanny.py", line 325, in test_command_usage self.validate_cmd(stderr=stderr) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/vstinner/python/Загрузки/Lib/test/test_tabnanny.py", line 297, in validate_cmd err = err.decode('ascii') ^^^^^^^^^^^^^^^^^^^ UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 29: ordinal not in range(128) (...) 

With this PR, it works as expected:

$ ./python -m test -v test_tabnanny (...) Tests result: SUCCESS 

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

LGTM.

@iritkatriel
Copy link
MemberAuthor

@raghavthind2005 FYI - there is a discussion on python-dev about spam activity on GitHub (which wastes our time) and your recent activity on the cpython repo was mentioned there.

See this link: https://mail.python.org/archives/list/python-dev@python.org/message/UO6ZSNWLLXWU7AZ7NGQDTOQ2WVX2ZAZN/

@iritkatrieliritkatriel merged commit 108e66b into python:mainFeb 1, 2022
@miss-islington
Copy link
Contributor

Thanks @iritkatriel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@iritkatrieliritkatriel deleted the bpo-44031-test_tabnanny branch February 1, 2022 10:32
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 1, 2022
(cherry picked from commit 108e66b) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
@bedevere-botbedevere-bot removed the needs backport to 3.10 only security fixes label Feb 1, 2022
@bedevere-bot
Copy link

GH-31047 is a backport of this pull request to the 3.10 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 1, 2022
(cherry picked from commit 108e66b) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
@bedevere-bot
Copy link

GH-31048 is a backport of this pull request to the 3.9 branch.

miss-islington added a commit that referenced this pull request Feb 1, 2022
(cherry picked from commit 108e66b) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
miss-islington added a commit that referenced this pull request Feb 1, 2022
GH-31048) (cherry picked from commit 108e66b) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Automerge-Triggered-By: GH:iritkatriel
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…-31014) (pythonGH-31048) (cherry picked from commit 108e66b) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Automerge-Triggered-By: GH:iritkatriel
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip newstestsTests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@iritkatriel@vstinner@miss-islington@bedevere-bot@raghavthind2005@the-knights-who-say-ni