|
29 | 29 | # Internals |
30 | 30 | # |
31 | 31 |
|
| 32 | +_WINERROR_NOT_READY = 21 # drive exists but is not accessible |
| 33 | +_WINERROR_INVALID_NAME = 123 # fix for bpo-35306 |
| 34 | +_WINERROR_CANT_RESOLVE_FILENAME = 1921 # broken symlink pointing to itself |
| 35 | + |
32 | 36 | # EBADF - guard against macOS `stat` throwing EBADF |
33 | 37 | _IGNORED_ERROS = (ENOENT, ENOTDIR, EBADF, ELOOP) |
34 | 38 |
|
35 | 39 | _IGNORED_WINERRORS = ( |
36 | | - 21, # ERROR_NOT_READY - drive exists but is not accessible |
37 | | - 123, # ERROR_INVALID_NAME - fix for bpo-35306 |
38 | | - 1921, # ERROR_CANT_RESOLVE_FILENAME - fix for broken symlink pointing to itself |
39 | | -) |
| 40 | + _WINERROR_NOT_READY, |
| 41 | + _WINERROR_INVALID_NAME, |
| 42 | + _WINERROR_CANT_RESOLVE_FILENAME) |
40 | 43 |
|
41 | 44 | def _ignore_error(exception): |
42 | 45 | return (getattr(exception, 'errno', None) in _IGNORED_ERROS or |
@@ -1061,7 +1064,8 @@ def resolve(self, strict=False): |
1061 | 1064 | try: |
1062 | 1065 | p = self._accessor.realpath(self, strict=strict) |
1063 | 1066 | except OSError as ex: |
1064 | | - if ex.errno == ELOOP: |
| 1067 | + winerr = getattr(ex, 'winerror', 0) |
| 1068 | + if ex.errno == ELOOP or winerr == _WINERROR_CANT_RESOLVE_FILENAME: |
1065 | 1069 | raise RuntimeError("Symlink loop from %r", ex.filename) |
1066 | 1070 | raise |
1067 | 1071 | return self._from_parts((p,)) |
|
0 commit comments