##// END OF EJS Templates
py3: catch specific OSError subclasses instead of checking errno...
Manuel Jacob -
r50205:050dc873 default
parent child Browse files
Show More
@@ -8,7 +8,6 b''
8 8
9 9 import collections
10 10 import contextlib
11 import errno
12 11 import os
13 12 import stat
14 13 import uuid
@@ -1035,13 +1034,11 b' class dirstate:'
1035 1034 try:
1036 1035 with tracing.log('dirstate.walk.traverse listdir %s', nd):
1037 1036 entries = listdir(join(nd), stat=True, skip=skip)
1038 except OSError as inst:
1039 if inst.errno in (errno.EACCES, errno.ENOENT):
1037 except (PermissionError, FileNotFoundError) as inst:
1040 1038 match.bad(
1041 1039 self.pathto(nd), encoding.strtolocal(inst.strerror)
1042 1040 )
1043 1041 continue
1044 raise
1045 1042 for f, kind, st in entries:
1046 1043 # Some matchers may return files in the visitentries set,
1047 1044 # instead of 'this', if the matcher explicitly mentions them
@@ -6,7 +6,6 b''
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8
9 import errno
10 9 import re
11 10
12 11 from .i18n import _
@@ -575,16 +574,14 b' class matchctx:'
575 574 return False
576 575 try:
577 576 return predfn(fctx)
578 except (IOError, OSError) as e:
579 # open()-ing a directory fails with EACCES on Windows
580 if e.errno in (
581 errno.ENOENT,
582 errno.EACCES,
583 errno.ENOTDIR,
584 errno.EISDIR,
577 # open()-ing a directory fails with PermissionError on Windows
578 except (
579 FileNotFoundError,
580 PermissionError,
581 NotADirectoryError,
582 IsADirectoryError,
585 583 ):
586 584 return False
587 raise
588 585
589 586 else:
590 587
@@ -38,9 +38,8 b' def _getlockprefix():'
38 38 if pycompat.sysplatform.startswith(b'linux'):
39 39 try:
40 40 result += b'/%x' % os.stat(b'/proc/self/ns/pid').st_ino
41 except OSError as ex:
42 if ex.errno not in (errno.ENOENT, errno.EACCES, errno.ENOTDIR):
43 raise
41 except (FileNotFoundError, PermissionError, NotADirectoryError):
42 pass
44 43 return result
45 44
46 45
@@ -581,9 +581,7 b' def statfiles(files):'
581 581 st = lstat(nf)
582 582 if getkind(st.st_mode) not in _wantedkinds:
583 583 st = None
584 except OSError as err:
585 if err.errno not in (errno.ENOENT, errno.ENOTDIR):
586 raise
584 except (FileNotFoundError, NotADirectoryError):
587 585 st = None
588 586 yield st
589 587
@@ -95,7 +95,6 b' else:'
95 95 ispypy = "PyPy" in sys.version
96 96
97 97 import ctypes
98 import errno
99 98 import stat, subprocess, time
100 99 import re
101 100 import shutil
@@ -1422,15 +1421,12 b' class RustExtension(Extension):'
1422 1421 )
1423 1422 try:
1424 1423 subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir)
1425 except OSError as exc:
1426 if exc.errno == errno.ENOENT:
1424 except FileNotFoundError:
1427 1425 raise RustCompilationError("Cargo not found")
1428 elif exc.errno == errno.EACCES:
1426 except PermissionError:
1429 1427 raise RustCompilationError(
1430 1428 "Cargo found, but permission to execute it is denied"
1431 1429 )
1432 else:
1433 raise
1434 1430 except subprocess.CalledProcessError:
1435 1431 raise RustCompilationError(
1436 1432 "Cargo failed. Working directory: %r, "
General Comments 0
You need to be logged in to leave comments. Login now