Skip to content

Commit 15206e8

Browse files
committed
优化代码
1 parent d467b98 commit 15206e8

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

feapder/db/redisdb.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import time
1111

1212
import redis
13-
from redis._compat import unicode, long, basestring
1413
from redis.connection import Encoder as _Encoder
1514
from redis.exceptions import ConnectionError, TimeoutError
1615
from redis.exceptions import DataError
@@ -34,19 +33,19 @@ def encode(self, value):
3433
# )
3534
elif isinstance(value, float):
3635
value = repr(value).encode()
37-
elif isinstance(value, (int, long)):
36+
elif isinstance(value, int):
3837
# python 2 repr() on longs is '123L', so use str() instead
3938
value = str(value).encode()
4039
elif isinstance(value, (list, dict, tuple)):
41-
value = unicode(value)
42-
elif not isinstance(value, basestring):
40+
value = str(value)
41+
elif not isinstance(value, str):
4342
# a value we don't know how to deal with. throw an error
4443
typename = type(value).__name__
4544
raise DataError(
4645
"Invalid input of type: '%s'. Convert to a "
4746
"bytes, string, int or float first." % typename
4847
)
49-
if isinstance(value, unicode):
48+
if isinstance(value, str):
5049
value = value.encode(self.encoding, self.encoding_errors)
5150
return value
5251

0 commit comments

Comments
 (0)