Skip to content

Commit 4b1e98b

Browse files
committed
Issue #29079: Prevent infinite loop in pathlib.resolve() on Windows
1 parent 4061939 commit 4b1e98b

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/pathlib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ def resolve(self, path, strict=False):
192192
s = self._ext_to_normal(_getfinalpathname(s))
193193
except FileNotFoundError:
194194
previous_s = s
195-
s = os.path.abspath(os.path.join(s, os.pardir))
195+
s = os.path.dirname(s)
196+
if previous_s == s:
197+
return path
196198
else:
197199
if previous_s is None:
198200
return s

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Core and Builtins
4040
Library
4141
-------
4242

43+
- Issue #29079: Prevent infinite loop in pathlib.resolve() on Windows
44+
4345
- Issue #13051: Fixed recursion errors in large or resized
4446
curses.textpad.Textbox. Based on patch by Tycho Andersen.
4547

0 commit comments

Comments
 (0)