Skip to content

Commit

Permalink
Merge pull request #1091 from dwf/unpickler_kwargs_run_travis_dammit
Browse files Browse the repository at this point in the history
Pass kwargs to unpickler, take 2 (Travis? Hello?)
  • Loading branch information
dwf committed May 19, 2016
2 parents 30ab153 + 5f797e8 commit ea1b751
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions blocks/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ def secure_dump(object_, path, dump_function=dump, **kwargs):
raise


def load(file_, name='_pkl', use_cpickle=False):
"""Loads an object saved using the `dump` function.
def load(file_, name='_pkl', use_cpickle=False, **kwargs):
r"""Loads an object saved using the `dump` function.
By default, this function loads the object saved by the `dump`
function. If some objects have been added to the archive using the
Expand All @@ -251,6 +251,10 @@ def load(file_, name='_pkl', use_cpickle=False):
the original object which have been dumped that is loaded.
use_cpickle : bool
Use cPickle instead of pickle. Default: False.
\*\*kwargs
Keyword arguments to be passed to `pickle.Unpickler`.
Used for e.g. specifying the encoding so as to load legacy Python
pickles under Python 3.x.
Returns
-------
Expand All @@ -264,7 +268,9 @@ def load(file_, name='_pkl', use_cpickle=False):
unpickler = pickle.Unpickler
with tarfile.open(fileobj=file_, mode='r') as tar_file:
p = unpickler(
tar_file.extractfile(tar_file.getmember(name)))
tar_file.extractfile(tar_file.getmember(name)),
**kwargs
)
if '_parameters' in tar_file.getnames():
p.persistent_load = _PersistentLoad(tar_file)
return p.load()
Expand Down

0 comments on commit ea1b751

Please sign in to comment.