mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
Isuse #17720: Fix APPENDS handling in the Python implementation of Unpickler
to correctly process the opcode when it is used on non-list objects.
This commit is contained in:
parent
bdf940d3bd
commit
1f7492c28a
3 changed files with 65 additions and 6 deletions
|
@ -1208,8 +1208,14 @@ class _Unpickler:
|
|||
def load_appends(self):
|
||||
stack = self.stack
|
||||
mark = self.marker()
|
||||
list = stack[mark - 1]
|
||||
list.extend(stack[mark + 1:])
|
||||
list_obj = stack[mark - 1]
|
||||
items = stack[mark + 1:]
|
||||
if isinstance(list_obj, list):
|
||||
list_obj.extend(items)
|
||||
else:
|
||||
append = list_obj.append
|
||||
for item in items:
|
||||
append(item)
|
||||
del stack[mark:]
|
||||
dispatch[APPENDS[0]] = load_appends
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue