summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2014-07-03 21:51:58 -0700
committerAndy McCurdy <andy@andymccurdy.com>2014-07-03 21:53:13 -0700
commit310cb1c58c059fc6d007a67edda8166fb4c962e6 (patch)
treedc3bacb9707d89ffa7f8bdf872cb047dee34b265
parent246db5b13c5b3c21263b9db42ebefaeb963d5bb9 (diff)
downloadredis-py-310cb1c58c059fc6d007a67edda8166fb4c962e6.tar.gz
Consistent option names for encoding and encoding_errors. Fixes #510
-rw-r--r--CHANGES7
-rwxr-xr-xredis/client.py18
-rwxr-xr-xredis/connection.py11
3 files changed, 32 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 32fce25..15f66f7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,13 @@
another thread to release it, you need to disable thread local storage.
Refer to the doc strings on the Lock class about the thread_local
argument information.
+ * Fixed a regression in from_url where "charset" and "errors" weren't
+ valid options. "encoding" and "encoding_errors" are still accepted
+ and preferred.
+ * The "charset" and "errors" options have been deprecated. Passing
+ either to StrictRedis.__init__ or from_url will still work but will
+ also emit a DeprecationWarning. Instead use the "encoding" and
+ "encoding_errors" options.
* 2.10.1
* Fixed a bug where Sentinel connections to a server that's no longer a
master and receives a READONLY error will disconnect and reconnect to
diff --git a/redis/client.py b/redis/client.py
index 0ab8081..9271e68 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -392,18 +392,28 @@ class StrictRedis(object):
db=0, password=None, socket_timeout=None,
socket_connect_timeout=None,
socket_keepalive=None, socket_keepalive_options=None,
- connection_pool=None, charset='utf-8', errors='strict',
+ connection_pool=None, unix_socket_path=None,
+ encoding='utf-8', encoding_errors='strict',
+ charset=None, errors=None,
decode_responses=False, retry_on_timeout=False,
- unix_socket_path=None,
ssl=False, ssl_keyfile=None, ssl_certfile=None,
ssl_cert_reqs=None, ssl_ca_certs=None):
if not connection_pool:
+ if charset is not None:
+ warnings.warn(DeprecationWarning(
+ '"charset" is deprecated. Use "encoding" instead'))
+ encoding = charset
+ if errors is not None:
+ warnings.warn(DeprecationWarning(
+ '"errors" is deprecated. Use "encoding_errors" instead'))
+ encoding_errors = errors
+
kwargs = {
'db': db,
'password': password,
'socket_timeout': socket_timeout,
- 'encoding': charset,
- 'encoding_errors': errors,
+ 'encoding': encoding,
+ 'encoding_errors': encoding_errors,
'decode_responses': decode_responses,
'retry_on_timeout': retry_on_timeout
}
diff --git a/redis/connection.py b/redis/connection.py
index 141731d..4c14233 100755
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -783,6 +783,17 @@ class ConnectionPool(object):
# update the arguments from the URL values
kwargs.update(url_options)
+
+ # backwards compatability
+ if 'charset' in kwargs:
+ warnings.warn(DeprecationWarning(
+ '"charset" is deprecated. Use "encoding" instead'))
+ kwargs['encoding'] = kwargs.pop('charset')
+ if 'errors' in kwargs:
+ warnings.warn(DeprecationWarning(
+ '"errors" is deprecated. Use "encoding_errors" instead'))
+ kwargs['encoding_errors'] = kwargs.pop('errors')
+
return cls(**kwargs)
def __init__(self, connection_class=Connection, max_connections=None,