diff -r 64640a02b0ca Lib/gzip.py --- a/Lib/gzip.py Mon Aug 27 10:03:23 2012 +0300 +++ b/Lib/gzip.py Tue Aug 28 23:32:23 2012 +0300 @@ -670,9 +670,9 @@ if not chunk: break g.write(chunk) - if g is not sys.stdout: + if g is not sys.stdout.buffer: g.close() - if f is not sys.stdin: + if f is not sys.stdin.buffer: f.close() if __name__ == '__main__':