New submission from Tom Hale <t...@hale.ee>:
The os.path and Path implementations of samefile() do not allow comparisons of symbolic links: % mkdir empty && chdir empty % ln -s non-existant broken % ln broken lnbroken % ls -i # Show inode numbers 19325632 broken@ 19325632 lnbroken@ % Yup, they are the same file... but... % python -c 'import os; print(os.path.samefile("lnbroken", "broken", follow_symlinks=False))' Traceback (most recent call last): File "<string>", line 1, in <module> TypeError: samefile() got an unexpected keyword argument 'follow_symlinks' % python -c 'import os; print(os.path.samefile("lnbroken", "broken"))' Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib/python3.8/genericpath.py", line 100, in samefile s1 = os.stat(f1) FileNotFoundError: [Errno 2] No such file or directory: 'lnbroken' % Both samefile()s use os.stat under the hood, but neither allow setting os.stat()'s `follow_symlinks` parameter. https://docs.python.org/3/library/os.html#os.stat https://docs.python.org/3/library/os.path.html#os.path.samefile https://docs.python.org/3/library/pathlib.html#pathlib.Path.samefile ---------- components: Library (Lib) messages: 383965 nosy: Tom Hale priority: normal severity: normal status: open title: Add follow_symlinks=True to {os.path,Path}.samefile type: behavior versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42778> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com