]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41401: Fix test_fspath_support in test_io. (GH-21640) (GH-22133) (GH-22135)
authorVictor Stinner <vstinner@python.org>
Mon, 7 Sep 2020 15:27:03 +0000 (17:27 +0200)
committerGitHub <noreply@github.com>
Mon, 7 Sep 2020 15:27:03 +0000 (17:27 +0200)
The error is exposed on non-UTF-8 locales.

(cherry picked from commit 67987acd5dc9776f55f4e139e2b3d9e7a6434d9f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit c73ee5acc96b4bbd6885156883b224b8cc3e470c)

Lib/test/test_io.py

index bea4342e7f0f9eb7be957e0d6eba503631981e1c..8eef332b8e4b58e235895ba7e818c3f48ed2d6a8 100644 (file)
@@ -922,7 +922,7 @@ class IOTest(unittest.TestCase):
                 self.assertEqual(f.read(), "egg\n")
 
         check_path_succeeds(FakePath(support.TESTFN))
-        check_path_succeeds(FakePath(support.TESTFN.encode('utf-8')))
+        check_path_succeeds(FakePath(os.fsencode(support.TESTFN)))
 
         with self.open(support.TESTFN, "w") as f:
             bad_path = FakePath(f.fileno())