We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b25c87d commit 714d92cCopy full SHA for 714d92c
1 file changed
src/requests/utils.py
@@ -283,12 +283,13 @@ def extract_zipped_paths(path):
283
return path
284
285
# 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))
+ suffix = os.path.splitext(member.split("/")[-1])[-1]
+ fd, extracted_path = tempfile.mkstemp(suffix=suffix)
+ try:
+ os.write(fd, zip_file.read(member))
+ finally:
+ os.close(fd)
292
+
293
return extracted_path
294
295
0 commit comments