8000 BF: Since savez could be used with BytesIO - check if file is a string · numpy/numpy@dc61b5e · GitHub
[go: up one dir, main page]

Skip to content

Commit dc61b5e

Browse files
committed
BF: Since savez could be used with BytesIO - check if file is a string
1 parent 8a22dd4 commit dc61b5e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

numpy/lib/npyio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ def _savez(file, args, kwds, compress, allow_pickle=True, pickle_kwargs=None):
630630

631631
# Since target file might be big enough to exceed capacity of a global
632632
# temporary directory, create temp file side-by-side with the target file.
633-
file_path, file_name = os.path.split(file)
634-
fd, tmpfile = tempfile.mkstemp(prefix=file_name, dir=file_path, suffix='-numpy.npy')
633+
file_dir, file_prefix = os.path.split(file) if _is_string_like(file) else (None, 'tmp')
634+
fd, tmpfile = tempfile.mkstemp(prefix=file_prefix, dir=file_dir, suffix='-numpy.npy')
635635
os.close(fd)
636636
try:
637637
for key, val in namedict.items():

0 commit comments

Comments
 (0)
0