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

test_site: test_underpth_basic() fails if the current directory is non-ASCII #109237

Closed
vstinner opened this issue Sep 10, 2023 · 1 comment
Closed
Labels
tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

vstinner commented Sep 10, 2023

Failure on GHA Windows x64 CI with PR #109229 which runs test_site in a non-ASCII working directory:

FAIL: test_underpth_basic (test.test_site._pthFileTests.test_underpth_basic)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\cpython\cpython\Lib\test\test_site.py", line 621, in test_underpth_basic
    self.assertEqual(
AssertionError: Lists differ: ['D:\[40 chars]_1460\udce6', 'D:\\a\\cpython\\cpython\\PCbuil[396 chars]18f'] != ['D:\[40 chars]_1460�', 'D:\\a\\cpython\\cpython\\PCbuild\\am[391 chars]18f']

First differing element 0:
'D:\\a\\cpython\\cpython\\build\\test_python_1460\udce6'
'D:\\a\\cpython\\cpython\\build\\test_python_1460�'

Diff is 690 characters long. Set self.maxDiff to None to see it. : sys.path is incorrect

build: https://github.com/python/cpython/actions/runs/6138224249/job/16654899364?pr=109229

Linked PRs

@vstinner vstinner added the tests Tests in the Lib/test dir label Sep 10, 2023
vstinner added a commit to vstinner/cpython that referenced this issue Sep 10, 2023
Fix test_site.test_underpth_basic() when the working directory
contains at least one non-ASCII character: encode the "._pth" file to
UTF-8 and enable the UTF-8 Mode to use UTF-8 for the child process
stdout.
@vstinner
Copy link
Member Author

Example:

vstinner@WIN C:\victor\python\main>mkdir héhé

vstinner@WIN C:\victor\python\main>cd héhé

vstinner@WIN C:\victor\python\main\héhé>..\python -m test test_site -v
(...)
======================================================================
FAIL: test_underpth_basic (test.test_site._pthFileTests.test_underpth_basic)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\victor\python\main\Lib\test\test_site.py", line 621, in test_underpth_basic
    self.assertEqual(
AssertionError: Lists differ: ['C:\[19 chars]in\\h\udce9h\udce9', 'C:\\victor\\python\\main[361 chars]emp'] != ['C:\[19 chars]in\\héhé', 'C:\\victor\\python\\main\\PCbuild\[351 chars]emp']

First differing element 0:
'C:\\victor\\python\\main\\h\udce9h\udce9'
'C:\\victor\\python\\main\\héhé'

- ['C:\\victor\\python\\main\\h\udce9h\udce9',
?                              ^^^^^^ ^^^^^^

+ ['C:\\victor\\python\\main\\héhé',
?                              ^ ^

   'C:\\victor\\python\\main\\PCbuild\\amd64\\python313_d.zip',
   'C:\\victor\\python\\main\\PCbuild\\amd64',
   'C:\\victor\\python\\main\\Lib',
   'C:\\Users\\vstinner\\AppData\\Roaming\\Python\\Python313\\site-packages',
   'C:\\victor\\python\\main',
   'C:\\victor\\python\\main\\Lib\\site-packages',
   'C:\\Users\\vstinner\\AppData\\Local\\Temp\\tmpesrsy5ed',
   'C:\\Users\\vstinner\\AppData\\Local\\Temp'] : sys.path is incorrect

----------------------------------------------------------------------
Ran 32 tests in 2.619s

FAILED (failures=1, skipped=2)
(...)

vstinner added a commit that referenced this issue Sep 10, 2023
Fix test_site.test_underpth_basic() when the working directory
contains at least one non-ASCII character: encode the "._pth" file to
UTF-8 and enable the UTF-8 Mode to use UTF-8 for the child process
stdout.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 10, 2023
…nGH-109238)

Fix test_site.test_underpth_basic() when the working directory
contains at least one non-ASCII character: encode the "._pth" file to
UTF-8 and enable the UTF-8 Mode to use UTF-8 for the child process
stdout.
(cherry picked from commit cbb3a6f)

Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 10, 2023
…nGH-109238)

Fix test_site.test_underpth_basic() when the working directory
contains at least one non-ASCII character: encode the "._pth" file to
UTF-8 and enable the UTF-8 Mode to use UTF-8 for the child process
stdout.
(cherry picked from commit cbb3a6f)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this issue Sep 10, 2023
…09238) (#109240)

gh-109237: Fix test_site for non-ASCII working directory (GH-109238)

Fix test_site.test_underpth_basic() when the working directory
contains at least one non-ASCII character: encode the "._pth" file to
UTF-8 and enable the UTF-8 Mode to use UTF-8 for the child process
stdout.
(cherry picked from commit cbb3a6f)

Co-authored-by: Victor Stinner <vstinner@python.org>
Yhg1s pushed a commit that referenced this issue Sep 12, 2023
…09238) (#109239)

gh-109237: Fix test_site for non-ASCII working directory (GH-109238)

Fix test_site.test_underpth_basic() when the working directory
contains at least one non-ASCII character: encode the "._pth" file to
UTF-8 and enable the UTF-8 Mode to use UTF-8 for the child process
stdout.
(cherry picked from commit cbb3a6f)

Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir
Projects
None yet
Development

No branches or pull requests

1 participant