"""
from pickle import Pickler, Unpickler
-from io import StringIO
+from io import BytesIO
import UserDict
import warnings
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
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()
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())
pass
class AnyDBMTestCase(unittest.TestCase):
- _dict = {'0': b'',
- 'a': b'Python:',
- 'b': b'Programming',
- 'c': b'the',
- 'd': b'way',
- 'f': b'Guido',
- 'g': b'intended',
+ _dict = {str8('0'): b'',
+ str8('a'): b'Python:',
+ str8('b'): b'Programming',
+ str8('c'): b'the',
+ str8('d'): b'way',
+ str8('f'): b'Guido',
+ str8('g'): b'intended',
}
def __init__(self, *args):
def test_anydbm_modification(self):
self.init_db()
f = anydbm.open(_fname, 'c')
- self._dict['g'] = f['g'] = b"indented"
+ self._dict[str8('g')] = f[str8('g')] = b"indented"
self.read_helper(f)
f.close()