Mercurial > public > mercurial-scm > hg
diff tests/run-tests.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 | 56f98406831b |
children | 2e726c934fcd |
line wrap: on
line diff
--- a/tests/run-tests.py Tue May 31 16:54:58 2022 +0200 +++ b/tests/run-tests.py Tue May 31 21:16:17 2022 +0200 @@ -1099,9 +1099,8 @@ try: os.mkdir(self._threadtmp) - except OSError as e: - if e.errno != errno.EEXIST: - raise + except FileExistsError: + pass name = self._tmpname self._testtmp = os.path.join(self._threadtmp, name) @@ -3277,9 +3276,8 @@ exceptionsdir = os.path.join(self._outputdir, b'exceptions') try: os.makedirs(exceptionsdir) - except OSError as e: - if e.errno != errno.EEXIST: - raise + except FileExistsError: + pass # Remove all existing exception reports. for f in os.listdir(exceptionsdir): @@ -3593,10 +3591,9 @@ try: os.symlink(sysexecutable, mypython) self._createdfiles.append(mypython) - except OSError as err: + except FileExistsError: # child processes may race, which is harmless - if err.errno != errno.EEXIST: - raise + pass elif WINDOWS and not os.getenv('MSYSTEM'): raise AssertionError('cannot run test on Windows without MSYSTEM') else: @@ -3706,9 +3703,8 @@ def makedirs(p): try: os.makedirs(p) - except OSError as e: - if e.errno != errno.EEXIST: - raise + except FileExistsError: + pass makedirs(self._pythondir) makedirs(self._bindir) @@ -3757,9 +3753,8 @@ covdir = os.path.join(self._installdir, b'..', b'coverage') try: os.mkdir(covdir) - except OSError as e: - if e.errno != errno.EEXIST: - raise + except FileExistsError: + pass osenvironb[b'COVERAGE_DIR'] = covdir