diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2018-11-14 15:42:28 -0800 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2018-11-14 15:42:28 -0800 |
commit | 9c446d5cb1308d5e17204a04de6be3364aeab4eb (patch) | |
tree | 36461af3ef04bf2d40f28fcdf939eaa9d4dbabff /redis/connection.py | |
parent | 46c1021f32e4081e847c85f5582916eb65166ac0 (diff) | |
download | redis-py-9c446d5cb1308d5e17204a04de6be3364aeab4eb.tar.gz |
use str() to encode int or long values
on python2.7, repr() on a long produces '123L', which is clearly not what
we want
Diffstat (limited to 'redis/connection.py')
-rwxr-xr-x | redis/connection.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/redis/connection.py b/redis/connection.py index 3ab9573..87beb01 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -112,8 +112,11 @@ class Encoder(object): # special case bool since it is a subclass of int raise DataError("Invalid input of type: 'bool'. Convert to a " "byte, string or number first.") - elif isinstance(value, (int, long, float)): + elif isinstance(value, float): value = repr(value).encode() + elif isinstance(value, (int, long)): + # python 2 repr() on longs is '123L', so use str() instead + value = str(value).encode() elif not isinstance(value, basestring): # a value we don't know how to deal with. throw an error typename = type(value).__name__ |