Skip to content

Commit eb49847

Browse files
Pequergbkrk
authored andcommitted
Remove non-standard __transient__ support
1 parent d986894 commit eb49847

1 file changed

Lines changed: 1 addition & 21 deletions

File tree

cloudpickle/cloudpickle.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,7 @@ def save_instancemethod(self, obj):
627627
dispatch[types.MethodType] = save_instancemethod
628628

629629
def save_inst(self, obj):
630-
"""Inner logic to save instance. Based off pickle.save_inst
631-
Supports __transient__"""
630+
"""Inner logic to save instance. Based off pickle.save_inst"""
632631
cls = obj.__class__
633632

634633
# Try the dispatch table (pickle module doesn't do it)
@@ -666,13 +665,6 @@ def save_inst(self, obj):
666665
getstate = obj.__getstate__
667666
except AttributeError:
668667
stuff = obj.__dict__
669-
#remove items if transient
670-
if hasattr(obj, '__transient__'):
671-
transient = obj.__transient__
672-
stuff = stuff.copy()
673-
for k in list(stuff.keys()):
674-
if k in transient:
675-
del stuff[k]
676668
else:
677669
stuff = getstate()
678670
pickle._keep_alive(stuff, memo)
@@ -735,8 +727,6 @@ def __getattribute__(self, item):
735727

736728
def save_reduce(self, func, args, state=None,
737729
listitems=None, dictitems=None, obj=None):
738-
"""Modified to support __transient__ on new objects
739-
Change only affects protocol level 2 (which is always used by PiCloud"""
740730
# Assert that args is a tuple or None
741731
if not isinstance(args, tuple):
742732
raise pickle.PicklingError("args from reduce() should be a tuple")
@@ -750,7 +740,6 @@ def save_reduce(self, func, args, state=None,
750740

751741
# Protocol 2 special case: if func's name is __newobj__, use NEWOBJ
752742
if self.proto >= 2 and getattr(func, "__name__", "") == "__newobj__":
753-
#Added fix to allow transient
754743
cls = args[0]
755744
if not hasattr(cls, "__new__"):
756745
raise pickle.PicklingError(
@@ -761,15 +750,6 @@ def save_reduce(self, func, args, state=None,
761750
args = args[1:]
762751
save(cls)
763752

764-
#Don't pickle transient entries
765-
if hasattr(obj, '__transient__'):
766-
transient = obj.__transient__
767-
state = state.copy()
768-
769-
for k in list(state.keys()):
770-
if k in transient:
771-
del state[k]
772-
773753
save(args)
774754
write(pickle.NEWOBJ)
775755
else:

0 commit comments

Comments
 (0)