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:
Alexandre Vassalotti 2013-04-20 13:19:46 -07:00
parent bdf940d3bd
commit 1f7492c28a
3 changed files with 65 additions and 6 deletions

View file

@ -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