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:
parent
4eade69201
commit
8984e550b0
1 changed files with 11 additions and 2 deletions
|
|
@ -3239,11 +3239,20 @@ 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
|
||||
infile = sys.stdin
|
||||
#
|
||||
# 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:
|
||||
outfile = sys.stdout
|
||||
# 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]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue