Skip to content

Commit 66d21cb

Browse files
authored
Merge commit from fork
1 parent 8b9bc8f commit 66d21cb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/requests/utils.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,13 @@ def extract_zipped_paths(path):
282282
return path
283283

284284
# we have a valid zip archive and a valid member of that archive
285-
tmp = tempfile.gettempdir()
286-
extracted_path = os.path.join(tmp, member.split("/")[-1])
287-
if not os.path.exists(extracted_path):
288-
# use read + write to avoid the creating nested folders, we only want the file, avoids mkdir racing condition
289-
with atomic_open(extracted_path) as file_handler:
290-
file_handler.write(zip_file.read(member))
285+
suffix = os.path.splitext(member.split("/")[-1])[-1]
286+
fd, extracted_path = tempfile.mkstemp(suffix=suffix)
287+
try:
288+
os.write(fd, zip_file.read(member))
289+
finally:
290+
os.close(fd)
291+
291292
return extracted_path
292293

293294

0 commit comments

Comments
 (0)