From 27a6103148a78100fc479f5dfc65065ef8e6ea72 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 11 Feb 2018 22:21:11 -0500 Subject: [PATCH] curl_httpclient: Only call native_str on debug message when needed Some debug messages are binary blobs that should not be decoded. Fixes #2275 --- tornado/curl_httpclient.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py index 1523fdcba..54fc5b36d 100644 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@ -499,10 +499,11 @@ class CurlAsyncHTTPClient(AsyncHTTPClient): def _curl_debug(self, debug_type, debug_msg): debug_types = ('I', '<', '>', '<', '>') - debug_msg = native_str(debug_msg) if debug_type == 0: + debug_msg = native_str(debug_msg) curl_log.debug('%s', debug_msg.strip()) elif debug_type in (1, 2): + debug_msg = native_str(debug_msg) for line in debug_msg.splitlines(): curl_log.debug('%s %s', debug_types[debug_type], line) elif debug_type == 4: -- 2.47.2