diff mercurial/win32.py @ 49313:53e9422a9b45

py3: catch FileExistsError instead of checking errno == EEXIST
author Manuel Jacob <me@manueljacob.de>
date Tue, 31 May 2022 21:16:17 +0200
parents d44e3c45f0e4
children a9faacdc5943
line wrap: on
line diff
--- a/mercurial/win32.py	Tue May 31 16:54:58 2022 +0200
+++ b/mercurial/win32.py	Tue May 31 21:16:17 2022 +0200
@@ -735,11 +735,10 @@
     for tries in range(10):
         temp = b'%s-%08x' % (f, random.randint(0, 0xFFFFFFFF))
         try:
-            os.rename(f, temp)  # raises OSError EEXIST if temp exists
+            os.rename(f, temp)
             break
-        except OSError as e:
-            if e.errno != errno.EEXIST:
-                raise
+        except FileExistsError:
+            pass
     else:
         raise IOError(errno.EEXIST, "No usable temporary filename found")