Skip to content

Commit 714d92c

Browse files
nateprewittalistairwatts
authored andcommitted
Merge commit from fork
1 parent b25c87d commit 714d92c

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/requests/utils.py

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

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

294295

0 commit comments

Comments
 (0)