@@ -33,10 +33,10 @@ def _captured_script(script):
33
33
return wrapped , open (r , encoding = "utf-8" )
34
34
35
35
36
- def _run_output (interp , request , shared = None ):
36
+ def _run_output (interp , request ):
37
37
script , rpipe = _captured_script (request )
38
38
with rpipe :
39
- interpreters .run_string (interp , script , shared )
39
+ interpreters .run_string (interp , script )
40
40
return rpipe .read ()
41
41
42
42
@@ -630,10 +630,10 @@ def test_shareable_types(self):
630
630
]
631
631
for obj in objects :
632
632
with self .subTest (obj ):
633
+ interpreters .set___main___attrs (interp , dict (obj = obj ))
633
634
interpreters .run_string (
634
635
interp ,
635
636
f'assert(obj == { obj !r} )' ,
636
- shared = dict (obj = obj ),
637
637
)
638
638
639
639
def test_os_exec (self ):
@@ -721,7 +721,8 @@ def test_with_shared(self):
721
721
with open({ w } , 'wb') as chan:
722
722
pickle.dump(ns, chan)
723
723
""" )
724
- interpreters .run_string (self .id , script , shared )
724
+ interpreters .set___main___attrs (self .id , shared )
725
+ interpreters .run_string (self .id , script )
725
726
with open (r , 'rb' ) as chan :
726
727
ns = pickle .load (chan )
727
728
@@ -742,7 +743,8 @@ def test_shared_overwrites(self):
742
743
ns2 = dict(vars())
743
744
del ns2['__builtins__']
744
745
""" )
745
- interpreters .run_string (self .id , script , shared )
746
+ interpreters .set___main___attrs (self .id , shared )
747
+ interpreters .run_string (self .id , script )
746
748
747
749
r , w = os .pipe ()
748
750
script = dedent (f"""
@@ -773,7 +775,8 @@ def test_shared_overwrites_default_vars(self):
773
775
with open({ w } , 'wb') as chan:
774
776
pickle.dump(ns, chan)
775
777
""" )
776
- interpreters .run_string (self .id , script , shared )
778
+ interpreters .set___main___attrs (self .id , shared )
779
+ interpreters .run_string (self .id , script )
777
780
with open (r , 'rb' ) as chan :
778
781
ns = pickle .load (chan )
779
782
@@ -1036,7 +1039,8 @@ def script():
1036
1039
with open (w , 'w' , encoding = "utf-8" ) as spipe :
1037
1040
with contextlib .redirect_stdout (spipe ):
1038
1041
print ('it worked!' , end = '' )
1039
- interpreters .run_func (self .id , script , shared = dict (w = w ))
1042
+ interpreters .set___main___attrs (self .id , dict (w = w ))
1043
+ interpreters .run_func (self .id , script )
1040
1044
1041
1045
with open (r , encoding = "utf-8" ) as outfile :
1042
1046
out = outfile .read ()
@@ -1052,7 +1056,8 @@ def script():
1052
1056
with contextlib .redirect_stdout (spipe ):
1053
1057
print ('it worked!' , end = '' )
1054
1058
def f ():
1055
- interpreters .run_func (self .id , script , shared = dict (w = w ))
1059
+ interpreters .set___main___attrs (self .id , dict (w = w ))
1060
+ interpreters .run_func (self .id , script )
1056
1061
t = threading .Thread (target = f )
1057
1062
t .start ()
1058
1063
t .join ()
@@ -1072,7 +1077,8 @@ def script():
1072
1077
with contextlib .redirect_stdout (spipe ):
1073
1078
print ('it worked!' , end = '' )
1074
1079
code = script .__code__
1075
- interpreters .run_func (self .id , code , shared = dict (w = w ))
1080
+ interpreters .set___main___attrs (self .id , dict (w = w ))
1081
+ interpreters .run_func (self .id , code )
1076
1082
1077
1083
with open (r , encoding = "utf-8" ) as outfile :
1078
1084
out = outfile .read ()
0 commit comments