diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-05-10 13:33:23 -0700 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-05-10 13:33:23 -0700 |
| commit | 11114bf0904c4b84a7044d11822ea6a0ed518b5d (patch) | |
| tree | 05f5ec752fcc48af482b9080a2913d9ea9cc9678 /memcache.py | |
| parent | fbc7f56e93e1523e1c09dc3da0c9faf545c4b34c (diff) | |
| download | python-memcached-11114bf0904c4b84a7044d11822ea6a0ed518b5d.tar.gz | |
Use io.BytesIO() in favor of StringIO to be python3 friendly
Diffstat (limited to 'memcache.py')
| -rw-r--r-- | memcache.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/memcache.py b/memcache.py index 7e33c84..0546ea8 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 |
