@@ -25,7 +25,7 @@ def __init__(
25
25
main_window : Union [EditorWidget , None ] = None ,
26
26
program_language : str = "python" ,
27
27
program_encoding : str = "utf-8" ,
28
- program_buffer : int = 8192000 ,
28
+ program_buffer : int = 1024 ,
29
29
):
30
30
"""
31
31
:param main_window: Pyside main window
@@ -83,18 +83,20 @@ def exec_code(self, exec_file_name, exec_prefix: Union[str, list] = None) -> Non
83
83
exec_file = reformat_os_file_path
84
84
# run program
85
85
if exec_prefix is None :
86
- execute_program_list = [self .compiler_path , exec_file ]
86
+ execute_program_param = [self .compiler_path , exec_file ]
87
87
else :
88
88
if isinstance (exec_prefix , str ):
89
- execute_program_list = [self .compiler_path , exec_prefix , exec_file ]
89
+ execute_program_param = [self .compiler_path , exec_prefix , exec_file ]
90
90
else :
91
- execute_program_list = list ()
92
- execute_program_list .append (self .compiler_path )
91
+ execute_program_param = list ()
92
+ execute_program_param .append (self .compiler_path )
93
93
for prefix in exec_prefix :
94
- execute_program_list .append (prefix )
95
- execute_program_list .append (exec_file )
94
+ execute_program_param .append (prefix )
95
+ execute_program_param .append (exec_file )
96
+ if sys .platform not in ["win32" , "cygwin" , "msys" ]:
97
+ execute_program_param = " " .join (execute_program_param )
96
98
self .process = subprocess .Popen (
97
- execute_program_list ,
99
+ execute_program_param ,
98
100
stdout = subprocess .PIPE ,
99
101
stderr = subprocess .PIPE ,
100
102
stdin = subprocess .PIPE ,
@@ -178,12 +180,16 @@ def print_and_clear_queue(self) -> None:
178
180
179
181
def read_program_output_from_process (self ) -> None :
180
182
while self .still_run_program :
181
- program_output_data : str = self .process .stdout .raw .read (self .program_buffer ).decode (self .program_encoding ,
182
- errors = "replace" )
183
+ program_output_data : str = self .process .stdout .read (
184
+ self .program_buffer ).decode (self .program_encoding , "replace" )
185
+ if self .process :
186
+ self .process .stdout .flush ()
183
187
self .run_output_queue .put_nowait (program_output_data )
184
188
185
189
def read_program_error_output_from_process (self ) -> None :
186
190
while self .still_run_program :
187
- program_error_output_data : str = self .process .stderr .raw .read (self .program_buffer ).decode (
188
- self .program_encoding , errors = "replace" )
191
+ program_error_output_data : str = self .process .stderr .read (
192
+ self .program_buffer ).decode (self .program_encoding , "replace" )
193
+ if self .process :
194
+ self .process .stderr .flush ()
189
195
self .run_error_queue .put_nowait (program_error_output_data )
0 commit comments