From faf9265c91e35c2e14c4fb78731ec694cce63d56 Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Fri, 4 Sep 2015 20:50:48 +0500 Subject: [PATCH] fixed compatibility with Twisted 15.4.0 --- scrapy/utils/response.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scrapy/utils/response.py b/scrapy/utils/response.py index 3d1af7e51..c4ad52f14 100644 --- a/scrapy/utils/response.py +++ b/scrapy/utils/response.py @@ -9,8 +9,7 @@ import webbrowser import tempfile from twisted.web import http -from twisted.web.http import RESPONSES -from scrapy.utils.python import to_bytes +from scrapy.utils.python import to_bytes, to_native_str from w3lib import html from scrapy.utils.decorators import deprecated @@ -55,7 +54,7 @@ def response_status_message(status): >>> response_status_message(404) '404 Not Found' """ - return '%s %s' % (status, http.responses.get(int(status))) + return '%s %s' % (status, to_native_str(http.RESPONSES.get(int(status)))) def response_httprepr(response): @@ -64,7 +63,7 @@ def response_httprepr(response): that was received (that's not exposed by Twisted). """ s = b"HTTP/1.1 " + to_bytes(str(response.status)) + b" " + \ - to_bytes(RESPONSES.get(response.status, b'')) + b"\r\n" + to_bytes(http.RESPONSES.get(response.status, b'')) + b"\r\n" if response.headers: s += response.headers.to_string() + b"\r\n" s += b"\r\n"