We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b9bc8f commit 66d21cbCopy full SHA for 66d21cb
1 file changed
src/requests/utils.py
@@ -282,12 +282,13 @@ def extract_zipped_paths(path):
282
return path
283
284
# 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))
+ 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)
291
+
292
return extracted_path
293
294
0 commit comments