@@ -1678,7 +1678,8 @@ def test_makefile_mode(self):
16781678 for mode in 'r' , 'rb' , 'rw' , 'w' , 'wb' :
16791679 with self .subTest (mode = mode ):
16801680 with socket .socket () as sock :
1681- with sock .makefile (mode ) as fp :
1681+ encoding = None if "b" in mode else "utf-8"
1682+ with sock .makefile (mode , encoding = encoding ) as fp :
16821683 self .assertEqual (fp .mode , mode )
16831684
16841685 def test_makefile_invalid_mode (self ):
@@ -5625,7 +5626,7 @@ def isTipcAvailable():
56255626 if not hasattr (socket , "AF_TIPC" ):
56265627 return False
56275628 try :
5628- f = open ("/proc/modules" )
5629+ f = open ("/proc/modules" , encoding = "utf-8" )
56295630 except (FileNotFoundError , IsADirectoryError , PermissionError ):
56305631 # It's ok if the file does not exist, is a directory or if we
56315632 # have not the permission to read it.
@@ -6222,7 +6223,7 @@ def test_errors(self):
62226223 meth = self .meth_from_sock (s )
62236224 self .assertRaisesRegex (
62246225 ValueError , "SOCK_STREAM" , meth , file )
6225- with open (os_helper .TESTFN , 'rt' ) as file :
6226+ with open (os_helper .TESTFN , encoding = "utf-8" ) as file :
62266227 with socket .socket () as s :
62276228 meth = self .meth_from_sock (s )
62286229 self .assertRaisesRegex (
0 commit comments