Skip to content

Commit a26910e

Browse files
committed
Fix the C implementation
1 parent 56774f8 commit a26910e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Modules/_pickle.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3666,6 +3666,19 @@ save_frozendict(PickleState *state, PicklerObject *self, PyObject *obj)
36663666
}
36673667
}
36683668

3669+
/* If the object is already in the memo, this means it is
3670+
recursive. In this case, throw away everything we put on the
3671+
stack, and fetch the object back from the memo. */
3672+
if (PyMemoTable_Get(self->memo, obj)) {
3673+
const char pop_mark_op = POP_MARK;
3674+
3675+
if (_Pickler_Write(self, &pop_mark_op, 1) < 0)
3676+
return -1;
3677+
if (memo_get(state, self, obj) < 0)
3678+
return -1;
3679+
return 0;
3680+
}
3681+
36693682
const char frozendict_op = FROZENDICT;
36703683
if (_Pickler_Write(self, &frozendict_op, 1) < 0) {
36713684
return -1;

0 commit comments

Comments
 (0)