Read from stdin in binary mode an let XML parser deal with encoding. Also write to stdout in binary mode as the output is already encoded.

This commit is contained in:
Eduard Braun 2015-12-09 00:30:16 +01:00
parent 4eade69201
commit 8984e550b0

View file

@ -3239,10 +3239,19 @@ def parse_args(args=None, ignore_additional_args=False):
# GZ: could catch a raised IOError here and report
else:
# GZ: could sniff for gzip compression here
#
# open the binary buffer of stdin and let XML parser handle decoding
try:
infile = sys.stdin.buffer
except AttributeError:
infile = sys.stdin
if options.outfilename:
outfile = maybe_gziped_file(options.outfilename, "wb")
else:
# open the binary buffer of stdout as the output is already encoded
try:
outfile = sys.stdout.buffer
except AttributeError:
outfile = sys.stdout
return options, [infile, outfile]