Something like
--- /home/user/Desktop/pythontex2.py 2019-12-14 04:27:04.718269040 +0300
+++ /usr/share/texlive/texmf-dist/scripts/pythontex/pythontex2.py 2019-12-14 04:15:23.189530900 +0300
@@ -1510,8 +1510,8 @@
basename = key_run.replace('#', '_')
out_file_name = os.path.expanduser(os.path.normcase(os.path.join(outputdir, basename + '.out')))
err_file_name = os.path.expanduser(os.path.normcase(os.path.join(outputdir, basename + '.err')))
- out_file = open(out_file_name, 'w', encoding=encoding)
- err_file = open(err_file_name, 'w', encoding=encoding)
+ out_file = subprocess.PIPE
+ err_file = subprocess.PIPE
script = os.path.expanduser(os.path.normcase(os.path.join(outputdir, basename)))
if os.path.isabs(script):
script_full = script
@@ -1550,11 +1550,11 @@
else:
raise
- proc.wait()
+ out_data, err_data = proc.communicate()
if proc.returncode != 0:
break
- out_file.close()
- err_file.close()
+ with open(out_file_name, 'wb') as out_file: out_file.write(out_data)
+ with open(err_file_name, 'wb') as err_file: err_file.write(err_data)
# Process saved stdout into file(s) that are included in the TeX document.
#
Anyways, open(..., encoding=encoding) is meaningless, because the file-like object is then passed to subprocess.Popen which is only interested in .fileno() of this file-like object.
Thanks.
Something like
Anyways,
open(..., encoding=encoding)is meaningless, because the file-like object is then passed tosubprocess.Popenwhich is only interested in.fileno()of this file-like object.Thanks.