8000 ENH: savez: temporary file alongside with target file and improve exception message upon IOError by yarikoptic · Pull Request #7133 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: savez: temporary file alongside with target file and improve exception message upon IOError #7133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 9, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ENH: for savez create temporary file alongside with the target file
Closes: gh-5336
  • Loading branch information
yarikoptic committed Jan 28, 2016
commit 33777c64fefbd0919d3cf8f832c302205b4ede23
6 changes: 5 additions & 1 deletion numpy/lib/npyio.py
7032
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,11 @@ def _savez(file, args, kwds, compress, allow_pickle=True, pickle_kwargs=None):
zipf = zipfile_factory(file, mode="w", compression=compression)

# Stage arrays in a temporary file on disk, before writing to zip.
fd, tmpfile = tempfile.mkstemp(suffix='-numpy.npy')

# Since target file might be big enough to exceed capacity of a global
# temporary directory, create temp file side-by-side with the target file.
file_path, file_name = os.path.split(file)
fd, tmpfile = tempfile.mkstemp(prefix=file_name, dir=file_path, suffix='-numpy.npy')
os.close(fd)
try:
for key, val in namedict.items():
Expand Down
0