Mercurial > public > mercurial-scm > hg
comparison mercurial/win32.py @ 49305: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 |
comparison
equal
deleted
inserted
replaced
49304:48f1b314056b | 49305:53e9422a9b45 |
---|---|
733 # implicit zombie filename blocking on a temporary name. | 733 # implicit zombie filename blocking on a temporary name. |
734 | 734 |
735 for tries in range(10): | 735 for tries in range(10): |
736 temp = b'%s-%08x' % (f, random.randint(0, 0xFFFFFFFF)) | 736 temp = b'%s-%08x' % (f, random.randint(0, 0xFFFFFFFF)) |
737 try: | 737 try: |
738 os.rename(f, temp) # raises OSError EEXIST if temp exists | 738 os.rename(f, temp) |
739 break | 739 break |
740 except OSError as e: | 740 except FileExistsError: |
741 if e.errno != errno.EEXIST: | 741 pass |
742 raise | |
743 else: | 742 else: |
744 raise IOError(errno.EEXIST, "No usable temporary filename found") | 743 raise IOError(errno.EEXIST, "No usable temporary filename found") |
745 | 744 |
746 try: | 745 try: |
747 os.unlink(temp) | 746 os.unlink(temp) |