There should be a data-only pickle serialization protocol (that won't serialize or deserialize code).
How much work would it be to create a pickle protocol that does not exec or eval code?
python/cpython//Lib/pickle.py: https://github.com/python/cpython/blob/main/Lib/pickle.py
python/cpython//Lib/pickletools.py: https://github.com/python/cpython/blob/main/Lib/pickletools....