To control what states of a custom defined object gets pickled and unpickled, use the __getstate__()
and __setstate__(self, state)
dunders.
__setstate__
is where a hacker may execute malicious code to hack your computer (i.e. by creating an external window session onto your machine)