Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21d7533

Browse files
Issue #23094: Fixed readline with frames in Python implementation of pickle.
1 parent 5106d04 commit 21d7533

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

Lib/pickle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def readline(self):
242242
if not data:
243243
self.current_frame = None
244244
return self.file_readline()
245-
if data[-1] != b'\n':
245+
if data[-1] != b'\n'[0]:
246246
raise UnpicklingError(
247247
"pickle exhausted before end of frame")
248248
return data

Lib/test/pickletester.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,14 @@ def remove_frames(pickled, keep_frame=None):
15381538
count_opcode(pickle.FRAME, pickled))
15391539
self.assertEqual(obj, self.loads(some_frames_pickle))
15401540

1541+
def test_frame_readline(self):
1542+
pickled = b'\x80\x04\x95\x05\x00\x00\x00\x00\x00\x00\x00I42\n.'
1543+
# 0: \x80 PROTO 4
1544+
# 2: \x95 FRAME 5
1545+
# 11: I INT 42
1546+
# 15: . STOP
1547+
self.assertEqual(self.loads(pickled), 42)
1548+
15411549
def test_nested_names(self):
15421550
global Nested
15431551
class Nested:

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Core and Builtins
5050
Library
5151
-------
5252

53+
- Issue #23094: Fixed readline with frames in Python implementation of pickle.
54+
5355
- Issue #23268: Fixed bugs in the comparison of ipaddress classes.
5456

5557
- Issue #21408: Removed incorrect implementations of __ne__() which didn't

0 commit comments

Comments
 (0)