From 9709c4f842fbb34bb93b874f465d14b53f90747c Mon Sep 17 00:00:00 2001 From: Mate Barany Date: Fri, 13 Sep 2024 13:21:35 +0200 Subject: [PATCH] Use replace instead of rename in localetools.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Unix, if target exists and it is a file, rename silently replaces it if the user has permission. However, on Windows, if the target exists, FileExistError will be raised. With replace, if target points to an existing file or empty directory, it will be unconditionally replaced. Change-Id: I2774152fec78a00c4ca6c9d1b927e503df2f2e84 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Edward Welbourne (cherry picked from commit eff8e6b885dfa3f26523ca39164725b4932c31bd) Reviewed-by: Qt Cherry-pick Bot --- util/locale_database/localetools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/locale_database/localetools.py b/util/locale_database/localetools.py index 02ec7cafc7a..dcc66a00749 100644 --- a/util/locale_database/localetools.py +++ b/util/locale_database/localetools.py @@ -99,7 +99,7 @@ def AtomicRenameTemporaryFile(originalLocation: Path, *, prefix: str, dir: Path) yield tempFile tempFile.close() # Move the modified file to the original location - Path(tempFile.name).rename(originalLocation) + Path(tempFile.name).replace(originalLocation) except Exception: # delete the temporary file in case of error tempFile.close()