File tree 1 file changed +15
-10
lines changed
1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -1056,20 +1056,25 @@ def resolve(self, strict=False):
1056
1056
Windows).
1057
1057
"""
1058
1058
1059
+ def check_eloop (e ):
1060
+ winerror = getattr (e , 'winerror' , 0 )
1061
+ if e .errno == ELOOP or winerror == _WINERROR_CANT_RESOLVE_FILENAME :
1062
+ raise RuntimeError ("Symlink loop from %r" % e .filename )
1063
+
1059
1064
try :
1060
1065
s = self ._accessor .realpath (self , strict = strict )
1061
- p = self ._from_parts ((s ,))
1066
+ except OSError as e :
1067
+ check_eloop (e )
1068
+ raise
1069
+ p = self ._from_parts ((s ,))
1062
1070
1063
- # In non-strict mode, realpath() doesn't raise on symlink loops.
1064
- # Ensure we get an exception by calling stat()
1065
- if not strict :
1071
+ # In non-strict mode, realpath() doesn't raise on symlink loops.
1072
+ # Ensure we get an exception by calling stat()
1073
+ if not strict :
1074
+ try :
1066
1075
p .stat ()
1067
- except OSError as ex :
1068
- winerror = getattr (ex , 'winerror' , 0 )
1069
- if ex .errno == ELOOP or winerror == _WINERROR_CANT_RESOLVE_FILENAME :
1070
- raise RuntimeError ("Symlink loop from %r" , ex .filename )
1071
- if strict :
1072
- raise
1076
+ except OSError as e :
1077
+ check_eloop (e )
1073
1078
return p
1074
1079
1075
1080
def stat (self , * , follow_symlinks = True ):
You can’t perform that action at this time.
0 commit comments