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 eryksun
Recipients eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2017-05-26.08:50:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1495788627.48.0.260495922264.issue30480@psf.upfronthosting.co.za>
In-reply-to
Content
os.path.samefile (used by shutil copyfile and move), os.path.sameopenfile, and pathlib.samefile rely on os.path.samestat (from genericpath.py), which compares corresponding st_dev and st_ino values. POSIX assures that the tuple (st_dev, st_ino) is unique. Windows makes no such assurance for the combination of the volume serial number (st_dev) and file index number (st_ino). The volume serial number isn't required to be unique or even non-zero ([MS-FSCC] 2.5.9), and the file index number may also be zero if the file system doesn't support it ([MS-FSCC] 2.4.20).

[MS-FSCC]: File System Control Codes
https://msdn.microsoft.com/en-us/library/cc231987

A WebDAV network drive exemplifies both cases. The volume serial number is zero, as is the file index number for every file and directory. Thus samestat() is true for every comparison on the drive, whether for a file or directory, and also when comparing files mounted on different WebDAV drives.

This isn't a common problem, but I think it's severe enough to warrant a separate Windows implementation of samefile and sameopenfile. If the corresponding st_dev and st_ino values are equal and either is zero, it should compare the final paths via _getfinalpathname. The latter would need to be modified to support passing a file descriptor for use with sameopenfile.
History
Date User Action Args
2017-05-26 08:50:27eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower
2017-05-26 08:50:27eryksunsetmessageid: <1495788627.48.0.260495922264.issue30480@psf.upfronthosting.co.za>
2017-05-26 08:50:27eryksunlinkissue30480 messages
2017-05-26 08:50:26eryksuncreate