Skip to content

Commit 6e762ce

Browse files
nyovkmike
authored andcommitted
PY3 renames (six types)
1 parent 3e6d6c4 commit 6e762ce

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

scrapy/core/downloader/handlers/s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from urlparse import unquote
1+
from six.moves.urllib.parse import unquote
22

33
from scrapy.exceptions import NotConfigured
44
from scrapy.utils.httpobj import urlparse_cached

scrapy/core/downloader/middleware.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
See documentation in docs/topics/downloader-middleware.rst
55
"""
6-
6+
import six
77
from scrapy.http import Request, Response
88
from scrapy.middleware import MiddlewareManager
99
from scrapy.utils.defer import mustbe_deferred
@@ -32,7 +32,7 @@ def process_request(request):
3232
response = method(request=request, spider=spider)
3333
assert response is None or isinstance(response, (Response, Request)), \
3434
'Middleware %s.process_request must return None, Response or Request, got %s' % \
35-
(method.im_self.__class__.__name__, response.__class__.__name__)
35+
(six.get_method_self(method).__class__.__name__, response.__class__.__name__)
3636
if response:
3737
return response
3838
return download_func(request=request, spider=spider)
@@ -46,7 +46,7 @@ def process_response(response):
4646
response = method(request=request, response=response, spider=spider)
4747
assert isinstance(response, (Response, Request)), \
4848
'Middleware %s.process_response must return Response or Request, got %s' % \
49-
(method.im_self.__class__.__name__, type(response))
49+
(six.get_method_self(method).__class__.__name__, type(response))
5050
if isinstance(response, Request):
5151
return response
5252
return response
@@ -57,7 +57,7 @@ def process_exception(_failure):
5757
response = method(request=request, exception=exception, spider=spider)
5858
assert response is None or isinstance(response, (Response, Request)), \
5959
'Middleware %s.process_exception must return None, Response or Request, got %s' % \
60-
(method.im_self.__class__.__name__, type(response))
60+
(six.get_method_self(method).__class__.__name__, type(response))
6161
if response:
6262
return response
6363
return _failure

scrapy/core/spidermw.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
See documentation in docs/topics/spider-middleware.rst
55
"""
6-
6+
import six
77
from twisted.python.failure import Failure
88
from scrapy.middleware import MiddlewareManager
99
from scrapy.utils.defer import mustbe_deferred
@@ -33,7 +33,9 @@ def _add_middleware(self, mw):
3333
self.methods['process_start_requests'].insert(0, mw.process_start_requests)
3434

3535
def scrape_response(self, scrape_func, response, request, spider):
36-
fname = lambda f:'%s.%s' % (f.im_self.__class__.__name__, f.im_func.__name__)
36+
fname = lambda f:'%s.%s' % (
37+
six.get_method_self(f).__class__.__name__,
38+
six.get_method_function(f).__name__)
3739

3840
def process_spider_input(response):
3941
for method in self.methods['process_spider_input']:

scrapy/linkextractors/htmlparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import warnings
6-
from HTMLParser import HTMLParser
6+
from six.moves.html_parser import HTMLParser
77
from six.moves.urllib.parse import urljoin
88

99
from w3lib.url import safe_url_string

tests/test_crawl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def test_start_requests_dupes(self):
141141
def test_unbounded_response(self):
142142
# Completeness of responses without Content-Length or Transfer-Encoding
143143
# can not be determined, we treat them as valid but flagged as "partial"
144-
from urllib import urlencode
144+
from six.moves.urllib.parse import urlencode
145145
query = urlencode({'raw': '''\
146146
HTTP/1.1 200 OK
147147
Server: Apache-Coyote/1.1

0 commit comments

Comments
 (0)