From b26241168314812cf30c4f93edf4e8ec45d2fe6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gra=C3=B1a?= Date: Tue, 29 Sep 2015 23:00:30 -0300 Subject: [PATCH] Backport fix compatibility with Twisted 15.4.0 --- scrapy/utils/response.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scrapy/utils/response.py b/scrapy/utils/response.py index b5d7a58ca..2b7b8544b 100644 --- a/scrapy/utils/response.py +++ b/scrapy/utils/response.py @@ -53,7 +53,10 @@ def response_status_message(status): >>> response_status_message(404) '404 Not Found' """ - return '%s %s' % (status, http.responses.get(int(status))) + # Implicit decode/encode is on purpose to force native strings + # This is properly fixed in Scrapy >=1.1 at revision faf9265 + reason = http.RESPONSES.get(int(status)).decode('utf8', errors='replace') + return '{} {}'.format(status, reason) def response_httprepr(response): """Return raw HTTP representation (as string) of the given response. This