mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #12687: Fix a possible buffering bug when unpickling text mode (protocol 0, mostly) pickles.
This commit is contained in:
parent
817495a631
commit
f6c7a8595e
3 changed files with 17 additions and 2 deletions
|
@ -1418,6 +1418,19 @@ class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):
|
|||
def test_multiple_unpicklings_unseekable(self):
|
||||
self._check_multiple_unpicklings(UnseekableIO)
|
||||
|
||||
def test_unpickling_buffering_readline(self):
|
||||
# Issue #12687: the unpickler's buffering logic could fail with
|
||||
# text mode opcodes.
|
||||
data = list(range(10))
|
||||
for proto in protocols:
|
||||
for buf_size in range(1, 11):
|
||||
f = io.BufferedRandom(io.BytesIO(), buffer_size=buf_size)
|
||||
pickler = self.pickler_class(f, protocol=proto)
|
||||
pickler.dump(data)
|
||||
f.seek(0)
|
||||
unpickler = self.unpickler_class(f)
|
||||
self.assertEqual(unpickler.load(), data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Print some stuff that can be used to rewrite DATA{0,1,2}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue