bpo-43651: Fix EncodingWarning in test_file and test_file_eintr (GH-25109)
https://github.com/python/cpython/commit/55f31be44b7e3ee24a67134f99543512a9b... commit: 55f31be44b7e3ee24a67134f99543512a9b630e4 branch: master author: Inada Naoki <songofacandy@gmail.com> committer: methane <songofacandy@gmail.com> date: 2021-04-01T11:23:03+09:00 summary: bpo-43651: Fix EncodingWarning in test_file and test_file_eintr (GH-25109) files: M Lib/test/test_file.py M Lib/test/test_file_eintr.py diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index 149767591d9eb..fbfba64759a1e 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -52,7 +52,7 @@ def testReadinto_text(self): # verify readinto refuses text files a = array('b', b'x'*10) self.f.close() - self.f = self.open(TESTFN, 'r') + self.f = self.open(TESTFN, encoding="utf-8") if hasattr(self.f, "readinto"): self.assertRaises(TypeError, self.f.readinto, a) diff --git a/Lib/test/test_file_eintr.py b/Lib/test/test_file_eintr.py index f1efd266ffb62..01408d838a83c 100644 --- a/Lib/test/test_file_eintr.py +++ b/Lib/test/test_file_eintr.py @@ -213,7 +213,7 @@ class TestTextIOSignalInterrupt(TestFileIOSignalInterrupt): def _generate_infile_setup_code(self): """Returns the infile = ... line of code to make a TextIOWrapper.""" return ('import %s as io ;' - 'infile = io.open(sys.stdin.fileno(), "rt", newline=None) ;' + 'infile = io.open(sys.stdin.fileno(), encoding="utf-8", newline=None) ;' 'assert isinstance(infile, io.TextIOWrapper)' % self.modname)
participants (1)
-
methane