summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-08-11 19:04:02 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-08-11 19:04:02 (GMT)
commitf6c7a8595ea77a2a470309127752432df2f6e872 (patch)
tree4d1d3bc3277c7ccf7180fc5c3eafcac6ccab050a /Lib
parent817495a63171d0bbfeaf03f3b5709e1dac399b5c (diff)
downloadcpython-f6c7a8595ea77a2a470309127752432df2f6e872.zip
cpython-f6c7a8595ea77a2a470309127752432df2f6e872.tar.gz
cpython-f6c7a8595ea77a2a470309127752432df2f6e872.tar.bz2
Issue #12687: Fix a possible buffering bug when unpickling text mode (protocol 0, mostly) pickles.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/pickletester.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index a843486..e4ab0dd 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -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}