When pathlib.resolve() is invoked on Windows(10) with an absolute path including a non-existing drive, it gets caught in an infinite loop. To reproduce: Select a drive letter that doesn't exist on the system (in my case H:). Run the following line of code: pathlib.Path('h:\\').resolve() Expected result: returns the input string unchanged. Actual result: pathlib.resolve() ends up in an infinite loop, repeatedly calling _getfinalpathname() on the same string.
I'm not sure the fix is correct. os.path.dirname(s) can point to different place than os.path.abspath(os.path.join(s, os.pardir)) if the last component of s is "..", "." or a symbolic link. Would be nice to add tests.
At the point this code is running, it doesn't matter. The path doesn't exist, so trimming irrelevant segments from it will just cause a few extra iterations through resolve until we clear out enough of the absent segments to find something that does exist. abspath just prepends the current working directory unless the path is rooted, so we essentially have unbounded concatenation of "\.." in that case.