diff --git a/scour/scour.py b/scour/scour.py index a62ee58..cb2d386 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -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]