cloudpipe / cloudpipe/cloudpickle

Override attributes are not pickled correctly

Open
#584 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.9k
Forks
195
Avg merge
1d 10h
Merged PRs (30d)
1

Description

When you have parent and child classes both have the same attribute, then the `__dict__` of each class should contains this attribute.
But when the attribute have the same value, cloudpickle will remove the attribute from the __dict__ of the sub class.

For Example:
```python
import cloudpickle
import gc

class A:
__version__ = 1

class B(A):
__version__ = 1

obj = B()
print('Obj: ', '__version__' in obj.__class__.__dict__)

s = cloudpickle.dumps(obj)

loaded_obj = cloudpickle.loads(s)

print('Loaded obj: ', '__version__' in loaded_obj.__class__.__dict__)

del A
del B
del obj
del loaded_obj
gc.collect()

loaded_obj = cloudpickle.loads(s)

print('Loaded obj after gc: ', '__version__' in loaded_obj.__class__.__dict__)
```

The output will be:
```
Obj: True
Loaded obj: True
Loaded obj after gc: False
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.