◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
35 changes: 18 additions & 17 deletions Lib/test/pickletester.py
Original file line number Diff line number Diff line change
Expand Up @@ -2781,29 +2781,30 @@ def test_clear_pickler_memo(self):
# object again, the third serialized form should be identical to the
# first one we obtained.
data = ["abcdefg", "abcdefg", 44]
f = io.BytesIO()
pickler = self.pickler_class(f)

pickler.dump(data)
first_pickled = f.getvalue()

# Reset BytesIO object.
f.seek(0)
f.truncate()

pickler.dump(data)
second_pickled = f.getvalue()

# Reset the Pickler and BytesIO objects.
pickler.clear_memo()
f.seek(0)
f.truncate()

pickler.dump(data)
third_pickled = f.getvalue()

self.assertNotEqual(first_pickled, second_pickled)
self.assertEqual(first_pickled, third_pickled)

def test_priming_pickler_memo(self):
# Verify that we can set the Pickler's memo attribute.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5 changes: 3 additions & 2 deletions Modules/_pickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -4152,9 +4152,10 @@ dump(PicklerObject *self, PyObject *obj)
}

if (save(self, obj, 0) < 0 ||
_Pickler_Write(self, &stop_op, 1) < 0)
return -1;

return 0;
}

Expand Down
Toggle all file notes Toggle all file annotations