Skip to content

Commit

Permalink
ensure tempfiles are deleted by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckerns committed Oct 20, 2022
1 parent 25a7e45 commit f8ea2a4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dill/temp.py
Expand Up @@ -106,6 +106,7 @@ def dump_source(object, **kwds):
""" #XXX: write a "load_source"?
from .source import importable, getname
import tempfile
kwds.setdefault('delete', True)
kwds.pop('suffix', '') # this is *always* '.py'
alias = kwds.pop('alias', '') #XXX: include an alias so a name is known
name = str(alias) or getname(object)
Expand Down Expand Up @@ -157,6 +158,7 @@ def dump(object, **kwds):
"""
import dill as pickle
import tempfile
kwds.setdefault('delete', True)
file = tempfile.NamedTemporaryFile(**kwds)
pickle.dump(object, file)
file.flush()
Expand Down

0 comments on commit f8ea2a4

Please sign in to comment.