@@ -25,11 +25,11 @@ def _captured_script(script):
2525 indented = script .replace ('\n ' , '\n ' )
2626 wrapped = dedent (f"""
2727 import contextlib
28- with open({ w } , 'w') as spipe:
28+ with open({ w } , 'w', encoding="utf-8" ) as spipe:
2929 with contextlib.redirect_stdout(spipe):
3030 { indented }
3131 """ )
32- return wrapped , open (r )
32+ return wrapped , open (r , encoding = "utf-8" )
3333
3434
3535def _run_output (interp , request , shared = None ):
@@ -45,7 +45,7 @@ def _running(interp):
4545 def run ():
4646 interpreters .run_string (interp , dedent (f"""
4747 # wait for "signal"
48- with open({ r } ) as rpipe:
48+ with open({ r } , encoding="utf-8" ) as rpipe:
4949 rpipe.read()
5050 """ ))
5151
@@ -54,7 +54,7 @@ def run():
5454
5555 yield
5656
57- with open (w , 'w' ) as spipe :
57+ with open (w , 'w' , encoding = "utf-8" ) as spipe :
5858 spipe .write ('done' )
5959 t .join ()
6060
@@ -806,7 +806,7 @@ def f():
806806 @unittest .skipUnless (hasattr (os , 'fork' ), "test needs os.fork()" )
807807 def test_fork (self ):
808808 import tempfile
809- with tempfile .NamedTemporaryFile ('w+' ) as file :
809+ with tempfile .NamedTemporaryFile ('w+' , encoding = "utf-8" ) as file :
810810 file .write ('' )
811811 file .flush ()
812812
@@ -816,7 +816,7 @@ def test_fork(self):
816816 try:
817817 os.fork()
818818 except RuntimeError:
819- with open('{ file .name } ', 'w') as out:
819+ with open('{ file .name } ', 'w', encoding='utf-8' ) as out:
820820 out.write('{ expected } ')
821821 """ )
822822 interpreters .run_string (self .id , script )
0 commit comments