summaryrefslogtreecommitdiffstats
path: root/Lib/shelve.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-07-26 03:07:02 (GMT)
committerBrett Cannon <bcannon@gmail.com>2007-07-26 03:07:02 (GMT)
commitd24fffe7c67c2097aa33e04498dc6b3ae0cc17ab (patch)
tree04bbb8451a4f171782f06a9e3e20c9922363880c /Lib/shelve.py
parent2f2fffb76689df57a93366121f30e078738c552b (diff)
downloadcpython-d24fffe7c67c2097aa33e04498dc6b3ae0cc17ab.zip
cpython-d24fffe7c67c2097aa33e04498dc6b3ae0cc17ab.tar.gz
cpython-d24fffe7c67c2097aa33e04498dc6b3ae0cc17ab.tar.bz2
Move shelve over to BytesIO as pickle.(Pickler | Unpickler) expect binary
files, not text files. test_shelve still fails thanks to bsddb not having been fixed.
Diffstat (limited to 'Lib/shelve.py')
-rw-r--r--Lib/shelve.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/shelve.py b/Lib/shelve.py
index 5aa8263..5759d4e 100644
--- a/Lib/shelve.py
+++ b/Lib/shelve.py
@@ -57,7 +57,7 @@ the persistent dictionary on disk, if feasible).
"""
from pickle import Pickler, Unpickler
-from io import StringIO
+from io import BytesIO
import UserDict
import warnings
@@ -97,7 +97,7 @@ class Shelf(UserDict.DictMixin):
try:
value = self.cache[key]
except KeyError:
- f = StringIO(self.dict[key])
+ f = BytesIO(self.dict[key])
value = Unpickler(f).load()
if self.writeback:
self.cache[key] = value
@@ -106,7 +106,7 @@ class Shelf(UserDict.DictMixin):
def __setitem__(self, key, value):
if self.writeback:
self.cache[key] = value
- f = StringIO()
+ f = BytesIO()
p = Pickler(f, self._protocol)
p.dump(value)
self.dict[key] = f.getvalue()
@@ -161,27 +161,27 @@ class BsdDbShelf(Shelf):
def set_location(self, key):
(key, value) = self.dict.set_location(key)
- f = StringIO(value)
+ f = BytesIO(value)
return (key, Unpickler(f).load())
def next(self):
(key, value) = next(self.dict)
- f = StringIO(value)
+ f = BytesIO(value)
return (key, Unpickler(f).load())
def previous(self):
(key, value) = self.dict.previous()
- f = StringIO(value)
+ f = BytesIO(value)
return (key, Unpickler(f).load())
def first(self):
(key, value) = self.dict.first()
- f = StringIO(value)
+ f = BytesIO(value)
return (key, Unpickler(f).load())
def last(self):
(key, value) = self.dict.last()
- f = StringIO(value)
+ f = BytesIO(value)
return (key, Unpickler(f).load())