Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
  • Loading branch information
tomMoral and ogrisel committed Nov 15, 2023
1 parent 00febd0 commit 9e2325c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cloudpickle/cloudpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,9 @@ def _class_setstate(obj, state):
else:
# Note: attribute names are automatically interned in cpython. This means that to get
# determinist pickling in subprocess, we need to make sure that the dynamic function names
# are also interned.
# are also interned since the Pickler's memoizer relies on physical object
# identity to break cycles in the reference graph of the object being
# serialized.
# https://github.com/python/cpython/blob/main/Objects/object.c#L1060
setattr(obj, attrname, attr)
if registry is not None:
Expand Down
6 changes: 4 additions & 2 deletions tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,10 @@ def assert_run_python_script(source_code, timeout=TIMEOUT):
def check_determinist_pickle(a, b):
"""Check that two pickle output are the same.
If it is not the case, print the diff between the disaembled pickle.
This helper is useful to investigate non-determinist pickle.
If it is not the case, print the diff between the disassembled pickle
payloads.
This helper is useful to investigate non-deterministic pickling.
"""
if a != b:
with io.StringIO() as out:
Expand Down

0 comments on commit 9e2325c

Please sign in to comment.