bpo-43651: Fix EncodingWarning in test_file and test_file_eintr (GH-25109)

This commit is contained in:
Inada Naoki 2021-04-01 11:23:03 +09:00 committed by GitHub
parent ad493edf57
commit 55f31be44b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -52,7 +52,7 @@ class AutoFileTests:
# 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)

View file

@ -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)