Do not attempt to close stdin/stdout file objects

This commit is contained in:
Eduard Braun 2016-09-18 03:07:51 +02:00
parent 8ac344daf2
commit 4a5b924d37

View file

@ -3758,8 +3758,12 @@ def start(options, input, output):
out_string = scourString(in_string, options).encode("UTF-8")
output.write(out_string)
# Close input and output files
# Close input and output files (but do not attempt to close stdin/stdout!)
if input is not sys.stdin:
if hasattr(input, 'buffer') and input is not sys.stdin.buffer:
input.close()
if output is not sys.stdout:
if hasattr(output, 'buffer') and output is not sys.stdout.buffer:
output.close()
end = walltime()