Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,8 @@ def load_reduce(self):
stack = self.stack
args = stack.pop()
func = stack[-1]
if not isinstance(args, tuple):
raise TypeError("argument list must be a tuple")
stack[-1] = func(*args)
dispatch[REDUCE[0]] = load_reduce

Expand Down
1 change: 1 addition & 0 deletions Lib/test/pickletester.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@ def test_bad_reduce(self):
self.assertEqual(self.loads(b'cbuiltins\nint\n)R.'), 0)
self.check_unpickling_error(TypeError, b'N)R.')
self.check_unpickling_error(TypeError, b'cbuiltins\nint\nNR.')
self.check_unpickling_error(TypeError, b'cbuiltins\nint\nNR.')
Comment on lines 1437 to +1438
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what this test adds?


def test_bad_newobj(self):
error = (pickle.UnpicklingError, TypeError)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``pickle.load_reduce()`` now requires a tuple for ``REDUCE`` arguments to
match ``_pickle``; non-tuple argument lists now raise ``TypeError``.
Loading