Skip to content

Commit f80f10a

Browse files
committed
Merge pull request scrapy#452 from alexanderlukanin13/python3
PY3: scrapy.__version__, NoneType, urlparse_monkeypatches
2 parents fa245af + 6c7292a commit f80f10a

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

scrapy/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from __future__ import print_function
55
import pkgutil
66
__version__ = pkgutil.get_data(__package__, 'VERSION').strip()
7+
if not isinstance(__version__, str):
8+
__version__ = __version__.decode('ascii')
79
version_info = tuple(__version__.split('.')[:3])
810

911
import sys, os, warnings

scrapy/utils/trackref.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
from collections import defaultdict
1515
from time import time
1616
from operator import itemgetter
17-
from types import NoneType
17+
18+
NoneType = type(None)
1819

1920
live_refs = defaultdict(weakref.WeakKeyDictionary)
2021

scrapy/xlib/urlparse_monkeypatches.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
from urlparse import urlparse
1+
import sys
22

3-
# workaround for http://bugs.python.org/issue7904 - Python < 2.7
4-
if urlparse('s3://bucket/key').netloc != 'bucket':
5-
from urlparse import uses_netloc
6-
uses_netloc.append('s3')
3+
if sys.version_info[0] == 2:
4+
from urlparse import urlparse
75

8-
# workaround for http://bugs.python.org/issue9374 - Python < 2.7.4
9-
if urlparse('s3://bucket/key?key=value').query != 'key=value':
10-
from urlparse import uses_query
11-
uses_query.append('s3')
6+
# workaround for http://bugs.python.org/issue7904 - Python < 2.7
7+
if urlparse('s3://bucket/key').netloc != 'bucket':
8+
from urlparse import uses_netloc
9+
uses_netloc.append('s3')
10+
11+
# workaround for http://bugs.python.org/issue9374 - Python < 2.7.4
12+
if urlparse('s3://bucket/key?key=value').query != 'key=value':
13+
from urlparse import uses_query
14+
uses_query.append('s3')

0 commit comments

Comments
 (0)