self.assertEqual(len(loaded), len(data))
self.assertEqual(loaded, data)
+ def test_empty_bytestring(self):
+ # issue 11286
+ empty = self.loads(b'\x80\x03U\x00q\x00.', encoding='koi8-r')
+ self.assertEqual(empty, '')
# Test classes for reduce_ex
f.seek(0)
return bytes(f.read())
- def loads(self, buf):
+ def loads(self, buf, **kwds):
f = io.BytesIO(buf)
- u = self.unpickler(f)
+ u = self.unpickler(f, **kwds)
return u.load()
def dumps(self, arg, proto=None):
return pickle.dumps(arg, proto)
- def loads(self, buf):
- return pickle.loads(buf)
+ def loads(self, buf, **kwds):
+ return pickle.loads(buf, **kwds)
class PyPersPicklerTests(AbstractPersistentPicklerTests):
f.seek(0)
return f.read()
- def loads(self, buf):
+ def loads(self, buf, **kwds):
class PersUnpickler(self.unpickler):
def persistent_load(subself, obj):
return self.persistent_load(obj)
f = io.BytesIO(buf)
- u = PersUnpickler(f)
+ u = PersUnpickler(f, **kwds)
return u.load()
def dumps(self, arg, proto=None):
return pickletools.optimize(pickle.dumps(arg, proto))
- def loads(self, buf):
- return pickle.loads(buf)
+ def loads(self, buf, **kwds):
+ return pickle.loads(buf, **kwds)
# Test relies on precise output of dumps()
test_pickle_to_2x = None
{
Py_ssize_t num_read;
- if (n == 0) {
- *s = NULL;
- return 0;
- }
-
if (self->next_read_idx + n <= self->input_len) {
*s = self->input_buffer + self->next_read_idx;
self->next_read_idx += n;