-
-
Notifications
You must be signed in to change notification settings - Fork 189
load_session() fails when dump_session() is used with byref=True #462
Copy link
Copy link
Closed
Labels
Milestone
Description
load_session() is failing even in the simplest cases when dump_session() was used with the byref parameter set to True:
>>> import dill
>>> x = 1
>>> dill.dump_session(byref=True)
# restart the interpreter, or not
>>> x = 0
>>> dill.load_session()
>>> x
0
# should have updated 'x' value
>>> del x
>>> dill.load_session()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/leogama/.local/lib/python3.8/site-packages/dill/_dill.py", line 423, in load_session
_restore_modules(main)
File "/home/leogama/.local/lib/python3.8/site-packages/dill/_dill.py", line 383, in _restore_modules
exec("from %s import %s" % (module, name), main_module.__dict__)
File "<string>", line 1, in <module>
ImportError: cannot import name 'x' from '__main__' (unknown location)Am I missing something? I tried to take a look at what happens differently when the byref option is used, but I don't understand the manipulations made to the __main__ module.
My setup:
- Ubuntu 20.04.4 LTS
- Linux 5.4.0-107
- Python 3.8.10
- dill 0.3.4
Reactions are currently unavailable