This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Tom Hale
Recipients Tom Hale
Date 2020-12-29.07:51:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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/", 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.
Date User Action Args
2020-12-29 07:51:01Tom Halesetrecipients: + Tom Hale
2020-12-29 07:51:01Tom Halesetmessageid: <>
2020-12-29 07:51:01Tom Halelinkissue42778 messages
2020-12-29 07:51:01Tom Halecreate