From 80ca92470938bbcc348e2d9cf4734c7c25cb1c43 Mon Sep 17 00:00:00 2001 From: ready-research <72916209+ready-research@users.noreply.github.com> Date: Tue, 16 May 2023 15:40:54 +0530 Subject: [PATCH] Use `mkstemp` to replace deprecated `mktemp` (#23372) * Use `mkstemp` to replace deprecated `mktemp` The `tempfile.mktemp` function is [deprecated](https://docs.python.org/3/library/tempfile.html#tempfile.mktemp) due to [security issues](https://cwe.mitre.org/data/definitions/377.html). * Update src/transformers/utils/hub.py Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com> --------- Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com> --- src/transformers/utils/hub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/utils/hub.py b/src/transformers/utils/hub.py index 58aac59d24e8e..335547f2b8259 100644 --- a/src/transformers/utils/hub.py +++ b/src/transformers/utils/hub.py @@ -578,7 +578,7 @@ def download_url(url, proxies=None): " that this is not compatible with the caching system (your file will be downloaded at each execution) or" " multiple processes (each process will download the file in a different temporary file)." ) - tmp_file = tempfile.mktemp() + tmp_file = tempfile.mkstemp()[1] with open(tmp_file, "wb") as f: http_get(url, f, proxies=proxies) return tmp_file