summaryrefslogtreecommitdiff
path: root/memcache.py
diff options
context:
space:
mode:
authorSean Reifschneider <jafo@tummy.com>2014-05-10 15:01:53 -0600
committerSean Reifschneider <jafo@tummy.com>2014-05-10 15:01:53 -0600
commit15207a06f42f0bdfe4b742dc17212512958d5426 (patch)
tree37870e8aacb4155a6b7128423f65a245859d2d62 /memcache.py
parent8a75759613dfb5a57c7c03d07075d2a518504c10 (diff)
parent11114bf0904c4b84a7044d11822ea6a0ed518b5d (diff)
downloadpython-memcached-15207a06f42f0bdfe4b742dc17212512958d5426.tar.gz
Merge pull request #41 from alex/stringio-py3k
Use io.BytesIO() in favor of StringIO to be python3 friendly
Diffstat (limited to 'memcache.py')
-rw-r--r--memcache.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/memcache.py b/memcache.py
index eca7ea6..5b5c18f 100644
--- a/memcache.py
+++ b/memcache.py
@@ -74,10 +74,7 @@ except ImportError:
def decompress(val):
raise _Error("received compressed data but I don't support compression (import error)")
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
+from io import BytesIO
valid_key_chars_re = re.compile('[\x21-\x7e\x80-\xff]+$')
@@ -225,7 +222,7 @@ class Client(local):
self.server_max_value_length = SERVER_MAX_VALUE_LENGTH
# figure out the pickler style
- file = StringIO()
+ file = BytesIO()
try:
pickler = self.pickler(file, protocol = self.pickleProtocol)
self.picklerIsKeyword = True
@@ -796,7 +793,7 @@ class Client(local):
min_compress_len = 0
else:
flags |= Client._FLAG_PICKLE
- file = StringIO()
+ file = BytesIO()
if self.picklerIsKeyword:
pickler = self.pickler(file, protocol = self.pickleProtocol)
else:
@@ -1044,7 +1041,7 @@ class Client(local):
val = long(buf)
elif flags & Client._FLAG_PICKLE:
try:
- file = StringIO(buf)
+ file = BytesIO(buf)
unpickler = self.unpickler(file)
if self.persistent_load:
unpickler.persistent_load = self.persistent_load