]> granicus.if.org Git - python/commitdiff
Issue #23094: Fixed readline with frames in Python implementation of pickle.
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 26 Jan 2015 08:37:01 +0000 (10:37 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 26 Jan 2015 08:37:01 +0000 (10:37 +0200)
Lib/pickle.py
Lib/test/pickletester.py
Misc/NEWS

index 663773f3d954064826153ab39cfaab9431fd8f97..e38ecac8249e0943dc6d24377647cc893807bbdc 100644 (file)
@@ -242,7 +242,7 @@ class _Unframer:
             if not data:
                 self.current_frame = None
                 return self.file_readline()
-            if data[-1] != b'\n':
+            if data[-1] != b'\n'[0]:
                 raise UnpicklingError(
                     "pickle exhausted before end of frame")
             return data
index 5963175ddd1565602345b8e3c9228a948de3a6fb..bdc7bad6dace9cbd81f0b39250b4ba48ba10403a 100644 (file)
@@ -1538,6 +1538,14 @@ class AbstractPickleTests(unittest.TestCase):
                             count_opcode(pickle.FRAME, pickled))
             self.assertEqual(obj, self.loads(some_frames_pickle))
 
+    def test_frame_readline(self):
+        pickled = b'\x80\x04\x95\x05\x00\x00\x00\x00\x00\x00\x00I42\n.'
+        #    0: \x80 PROTO      4
+        #    2: \x95 FRAME      5
+        #   11: I    INT        42
+        #   15: .    STOP
+        self.assertEqual(self.loads(pickled), 42)
+
     def test_nested_names(self):
         global Nested
         class Nested:
index b4a545129840994bcd3b6057c0dd4b3eadbe6f0a..c30c9d589f26fe84786d1b2a60b04b8a604d2096 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -50,6 +50,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #23094: Fixed readline with frames in Python implementation of pickle.
+
 - Issue #23268: Fixed bugs in the comparison of ipaddress classes.
 
 - Issue #21408: Removed incorrect implementations of __ne__() which didn't