From 65403864952558dce9fe00c9dbd32a0645e61968 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sat, 3 Apr 2021 22:08:45 +0900 Subject: [PATCH 1/7] Fix test_float --- Lib/test/test_float.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 99c81f0b72a5a3..ff4f3876be5cd3 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -729,7 +729,7 @@ def test_format(self): @support.requires_IEEE_754 def test_format_testfile(self): - with open(format_testfile) as testfile: + with open(format_testfile, encoding="utf-8") as testfile: for line in testfile: if line.startswith('--'): continue @@ -769,7 +769,7 @@ def test_issue35560(self): class ReprTestCase(unittest.TestCase): def test_repr(self): with open(os.path.join(os.path.split(__file__)[0], - 'floating_points.txt')) as floats_file: + 'floating_points.txt'), encoding="utf-8") as floats_file: for line in floats_file: line = line.strip() if not line or line.startswith('#'): From 0b907375674d4192a653b375a4e22b586af278f0 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sat, 3 Apr 2021 22:09:18 +0900 Subject: [PATCH 2/7] Fix _osx_support --- Lib/_osx_support.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/_osx_support.py b/Lib/_osx_support.py index 37975fe8a3eefa..303c9c46450306 100644 --- a/Lib/_osx_support.py +++ b/Lib/_osx_support.py @@ -96,7 +96,7 @@ def _get_system_version(): if _SYSTEM_VERSION is None: _SYSTEM_VERSION = '' try: - f = open('/System/Library/CoreServices/SystemVersion.plist') + f = open('/System/Library/CoreServices/SystemVersion.plist', encoding="utf-8") except OSError: # We're on a plain darwin box, fall back to the default # behaviour. From 60322ad7c20a74c2489536feb27d5bb54f60ad86 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sat, 3 Apr 2021 22:11:54 +0900 Subject: [PATCH 3/7] Fix test_fstring --- Lib/test/test_fstring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py index 79e123f4b8cec6..296cb05285c480 100644 --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -1110,7 +1110,7 @@ def test_filename_in_syntaxerror(self): # see issue 38964 with temp_cwd() as cwd: file_path = os.path.join(cwd, 't.py') - with open(file_path, 'w') as f: + with open(file_path, 'w', encoding="utf-8") as f: f.write('f"{a b}"') # This generates a SyntaxError _, _, stderr = assert_python_failure(file_path, PYTHONIOENCODING='ascii') From 3a0f04846f7556c66982c0aa12383800527ef5b1 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sat, 3 Apr 2021 22:12:02 +0900 Subject: [PATCH 4/7] Fix test_gc --- Lib/test/test_gc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index ba667370159063..ee4fe49a57f2af 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -750,7 +750,7 @@ def __del__(self): a.link = a raise SystemExit(0)""" self.addCleanup(unlink, TESTFN) - with open(TESTFN, 'w') as script: + with open(TESTFN, 'w', encoding="utf-8") as script: script.write(code) rc, out, err = assert_python_ok(TESTFN) self.assertEqual(out.strip(), b'__del__ called') From ae0ee36693575e676d4c50045fcfd0b10ab5ec9e Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sat, 3 Apr 2021 22:16:51 +0900 Subject: [PATCH 5/7] Fix test_gzip --- Lib/test/test_gzip.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 1dcfa2b628a1ca..446b61ab439ffe 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -660,14 +660,14 @@ def test_implicit_binary_modes(self): def test_text_modes(self): uncompressed = data1.decode("ascii") * 50 uncompressed_raw = uncompressed.replace("\n", os.linesep) - with gzip.open(self.filename, "wt") as f: + with gzip.open(self.filename, "wt", encoding="ascii") as f: f.write(uncompressed) with open(self.filename, "rb") as f: file_data = gzip.decompress(f.read()).decode("ascii") self.assertEqual(file_data, uncompressed_raw) - with gzip.open(self.filename, "rt") as f: + with gzip.open(self.filename, "rt", encoding="ascii") as f: self.assertEqual(f.read(), uncompressed) - with gzip.open(self.filename, "at") as f: + with gzip.open(self.filename, "at", encoding="ascii") as f: f.write(uncompressed) with open(self.filename, "rb") as f: file_data = gzip.decompress(f.read()).decode("ascii") @@ -681,7 +681,7 @@ def test_fileobj(self): self.assertEqual(f.read(), uncompressed_bytes) with gzip.open(io.BytesIO(compressed), "rb") as f: self.assertEqual(f.read(), uncompressed_bytes) - with gzip.open(io.BytesIO(compressed), "rt") as f: + with gzip.open(io.BytesIO(compressed), "rt", encoding="ascii") as f: self.assertEqual(f.read(), uncompressed_str) def test_bad_params(self): @@ -722,9 +722,9 @@ def test_encoding_error_handler(self): def test_newline(self): # Test with explicit newline (universal newline mode disabled). uncompressed = data1.decode("ascii") * 50 - with gzip.open(self.filename, "wt", newline="\n") as f: + with gzip.open(self.filename, "wt", encoding="ascii", newline="\n") as f: f.write(uncompressed) - with gzip.open(self.filename, "rt", newline="\r") as f: + with gzip.open(self.filename, "rt", encoding="ascii", newline="\r") as f: self.assertEqual(f.readlines(), [uncompressed]) From b4c4e5a0ac00c53ac32fc14aae9ba7ff1b469aa9 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sat, 3 Apr 2021 22:16:56 +0900 Subject: [PATCH 6/7] Fix test_hashlib --- Lib/test/test_hashlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index f50a4559269d78..0e06fdc9885dc5 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -82,7 +82,7 @@ def hexstr(s): def read_vectors(hash_name): url = URL.format(hash_name) try: - testdata = support.open_urlresource(url) + testdata = support.open_urlresource(url, encoding="utf-8") except (OSError, HTTPException): raise unittest.SkipTest("Could not retrieve {}".format(url)) with testdata: From aac36c313f4004e5370aacb9161e440786dd702f Mon Sep 17 00:00:00 2001 From: Ned Deily Date: Sat, 3 Apr 2021 22:18:17 -0400 Subject: [PATCH 7/7] Fix unrelated whitespace issue --- Lib/_osx_support.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/_osx_support.py b/Lib/_osx_support.py index 303c9c46450306..72f4819c29092a 100644 --- a/Lib/_osx_support.py +++ b/Lib/_osx_support.py @@ -156,9 +156,9 @@ def _default_sysroot(cc): if _cache_default_sysroot is not None: return _cache_default_sysroot - + contents = _read_output('%s -c -E -v - "): in_incdirs = True