Message383965
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 |
|
Date |
User |
Action |
Args |
2020-12-29 07:51:01 | Tom Hale | set | recipients:
+ Tom Hale |
2020-12-29 07:51:01 | Tom Hale | set | messageid: <1609228261.66.0.888283704166.issue42778@roundup.psfhosted.org> |
2020-12-29 07:51:01 | Tom Hale | link | issue42778 messages |
2020-12-29 07:51:01 | Tom Hale | create | |
|