Method that doesn't break on Python 3.

This commit is contained in:
Itamar Turner-Trauring 2021-06-15 14:03:58 -04:00
parent 23a71db38d
commit e8308043e3

View File

@ -97,9 +97,10 @@ def format_http_success(resp):
return "%s %s" % (resp.status, quote_output(resp.reason, quotemarks=False))
def format_http_error(msg, resp):
# ensure_text() shouldn't be necessary when Python 2 is dropped.
return quote_output(
"%s: %s %s\n%s" % (msg, resp.status, str(resp.reason, "utf-8"),
str(resp.read(), "utf-8")),
"%s: %s %s\n%s" % (msg, resp.status, six.ensure_text(resp.reason),
six.ensure_text(resp.read())),
quotemarks=False)
def check_http_error(resp, stderr):