From 9634dca7d84e5e013c8a0a54b2f6960a0aa74fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Roztoc=CC=8Cil?= Date: Fri, 2 Mar 2012 02:36:21 +0100 Subject: [PATCH] Fixed a `UnicodeError` in Python 2.6. --- httpie/httpie.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/httpie/httpie.py b/httpie/httpie.py index 236044c2..1aa595ce 100755 --- a/httpie/httpie.py +++ b/httpie/httpie.py @@ -108,7 +108,7 @@ parser.add_argument('items', metavar='item', nargs='*', def main(args=None, stdin=sys.stdin, - stdin_isatty=sys.stdout.isatty(), + stdin_isatty=sys.stdin.isatty(), stdout=sys.stdout, stdout_isatty=sys.stdout.isatty()): @@ -166,7 +166,7 @@ def main(args=None, encoding = response.encoding or 'ISO-8859-1' original = response.raw._original_response status_line, headers, body = ( - u'HTTP/{version} {status} {reason}'.format( + 'HTTP/{version} {status} {reason}'.format( version='.'.join(str(original.version)), status=original.status, reason=original.reason, ), @@ -185,10 +185,11 @@ def main(args=None, if args.print_headers: stdout.write(status_line) stdout.write('\n') - stdout.write(headers) + stdout.write(headers.encode('utf-8')) stdout.write('\n') if args.print_body: - stdout.write(body) + stdout.write(body.encode('utf-8')) + stdout.write('\n') if __name__ == '__main__': main()