Skip to content

Commit

Permalink
Fix load_session() and restrict loading a session in a different modu…
Browse files Browse the repository at this point in the history
…le (#507)

* Don't update vars(main) twice

* Inspect the pickle beginnig to identify main and check against 'main' argument

* Save and restore modules created at runtime with ModuleType()

* tests: don't need to add runtime module to sys.modules

* load_session_copy(): load a session state into a runtime module

* tests: session tests code reorganization

* tests: test runtime created module session saving

* tests: test load_session_copy

* review: adjustments

* small fixes

* use __dict__

* naming changes

* review: final renaming and adjustments
  • Loading branch information
leogama committed Jul 10, 2022
1 parent 0802fdd commit 0fa524a
Show file tree
Hide file tree
Showing 4 changed files with 558 additions and 193 deletions.
12 changes: 7 additions & 5 deletions dill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
del os, sys, parent, get_license_text, get_readme_as_rst


from ._dill import dump, dumps, load, loads, dump_session, load_session, \
Pickler, Unpickler, register, copy, pickle, pickles, check, \
HIGHEST_PROTOCOL, DEFAULT_PROTOCOL, PicklingError, UnpicklingError, \
HANDLE_FMODE, CONTENTS_FMODE, FILE_FMODE, PickleError, PickleWarning, \
PicklingWarning, UnpicklingWarning
from ._dill import (
dump, dumps, load, loads, dump_module, load_module, load_module_asdict,
dump_session, load_session, Pickler, Unpickler, register, copy, pickle,
pickles, check, HIGHEST_PROTOCOL, DEFAULT_PROTOCOL, PicklingError,
UnpicklingError, HANDLE_FMODE, CONTENTS_FMODE, FILE_FMODE, PickleError,
PickleWarning, PicklingWarning, UnpicklingWarning,
)
from . import source, temp, detect

# get global settings
Expand Down

0 comments on commit 0fa524a

Please sign in to comment.