New submission from John Engelke <john.enge...@gmail.com>:
The below snippet results in the symlink "/home" resolving as expected. However, documentation at https://docs.python.org/3.7/library/pathlib.html#pathlib.Path.resolve suggests, "If strict is False, the path is resolved as far as possible and any remainder is appended without checking whether it exists." >>> from pathlib import Path >>> host_path_str = "/home/somewhere/there/../nowhere" >>> host_path = Path(host_path_str) >>> host_path PosixPath('/home/somewhere/there/../nowhere') >>> host_path.resolve() PosixPath('/System/Volumes/Data/home/somewhere/nowhere') Expected results (based on the wording above): >>> host_path.resolve() PosixPath('/System/Volumes/Data/home/somewhere/there/../nowhere') Right now the ".." pieces are universally removed. I'm not exactly sure exactly how symlinks resolve, but this might create unexpected results. No part of the path component "somewhere/there/../nowhere" exists. When strict=True this would yield an error. So when strict=False, and it doesn't resolve, documentation implies that would be re-added to the resolved section. ---------- components: Library (Lib) messages: 381844 nosy: john.engelke priority: normal severity: normal status: open title: Pathlib resolve() resolves non-existent ".." components with strict=False type: behavior versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42464> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com