Isuse #17720: Fix APPENDS handling in the Python implementation of Unpickler
to correctly process the opcode when it is used on non-list objects.
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 161c2e9..1d8185c 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -1208,8 +1208,14 @@
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