@@ -189,27 +189,25 @@ def compile_pattern(self, pattern):
189
189
def resolve (self , path , strict = False ):
190
190
s = str (path )
191
191
if not s :
192
- return path ._accessor .getcwd ()
192
+ s = path ._accessor .getcwd ()
193
+ if _getfinalpathname is None :
194
+ return None # Means fallback on absolute
195
+ if strict :
196
+ return self ._ext_to_normal (_getfinalpathname (s ))
197
+ s = path = os .path .abspath (s )
193
198
previous_s = None
194
- if _getfinalpathname is not None :
195
- if strict :
196
- return self ._ext_to_normal (_getfinalpathname (s ))
199
+ tail_parts = [] # End of the path after the first one not found
200
+ while True :
201
+ try :
202
+ s = self ._ext_to_normal (_getfinalpathname (s ))
203
+ except FileNotFoundError :
204
+ previous_s = s
205
+ s , tail = os .path .split (s )
206
+ tail_parts .append (tail )
207
+ if previous_s == s : # Root reached, fallback to abspath()
208
+ return path
197
209
else :
198
- s = path = os .path .abspath (s )
199
- tail_parts = [] # End of the path after the first one not found
200
- while True :
201
- try :
202
- s = self ._ext_to_normal (_getfinalpathname (s ))
203
- except FileNotFoundError :
204
- previous_s = s
205
- s , tail = os .path .split (s )
206
- tail_parts .append (tail )
207
- if previous_s == s :
208
- return path
209
- else :
210
- return os .path .join (s , * reversed (tail_parts ))
211
- # Means fallback on absolute
212
- return None
210
+ return os .path .join (s , * reversed (tail_parts ))
213
211
214
212
def _split_extended_path (self , s , ext_prefix = ext_namespace_prefix ):
215
213
prefix = ''
0 commit comments