Skip to content

Commit c23a860

Browse files
Add option to decode responses in python3 (#146)
1 parent 02ae1ea commit c23a860

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/scrapy_redis/connection.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
import six
24

35
from scrapy.utils.misc import load_object
@@ -14,6 +16,9 @@
1416
'REDIS_ENCODING': 'encoding',
1517
}
1618

19+
if sys.version_info > (3,):
20+
SETTINGS_PARAMS_MAP['REDIS_DECODE_RESPONSES'] = 'decode_responses'
21+
1722

1823
def get_redis_from_settings(settings):
1924
"""Returns a redis client instance from given Scrapy settings object.
@@ -47,6 +52,11 @@ def get_redis_from_settings(settings):
4752
REDIS_PARAMS : dict, optional
4853
Additional client parameters.
4954
55+
Python 3 Only
56+
----------------
57+
REDIS_DECODE_RESPONSES : bool, optional
58+
Sets the `decode_responses` kwarg in Redis cls ctor
59+
5060
"""
5161
params = defaults.REDIS_PARAMS.copy()
5262
params.update(settings.getdict('REDIS_PARAMS'))

0 commit comments

Comments
 (0)