summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-01-26 08:37:44 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-01-26 08:37:44 (GMT)
commit230586739cc090ededbe45f101d8df75e5772455 (patch)
treeef441ff65c93df237a487a69c637c9ee349f9653
parent0e992b352aff5fae23ee0f8893e68ce27cba6af7 (diff)
parent21d7533c4c13489b4b3baae59f9e25cd038fb16b (diff)
downloadcpython-230586739cc090ededbe45f101d8df75e5772455.zip
cpython-230586739cc090ededbe45f101d8df75e5772455.tar.gz
cpython-230586739cc090ededbe45f101d8df75e5772455.tar.bz2
Issue #23094: Fixed readline with frames in Python implementation of pickle.
-rw-r--r--Lib/pickle.py2
-rw-r--r--Lib/test/pickletester.py8
-rw-r--r--Misc/NEWS2
3 files changed, 11 insertions, 1 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 663773f..e38ecac 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -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
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 444a103..5cd08d9 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -1584,6 +1584,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:
diff --git a/Misc/NEWS b/Misc/NEWS
index 2e67509..15f763c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -218,6 +218,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