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.

Title: Add ntpath.sameopenfile support for Windows
Type: enhancement Stage: resolved
Components: Windows Versions: Python 3.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brian.curtin Nosy List: akrpic77, asvetlov, brian.curtin, eric.smith, jaraco, loewis
Priority: normal Keywords: patch

Created on 2009-12-23 00:56 by jaraco, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
issue7566.diff brian.curtin, 2010-07-23 19:50
Messages (5)
msg96822 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2009-12-23 00:56
In issue1578269, asvetlov suggests adding an implementation of
os.sameopenfile to

Jason, as I see you implemented os.samefile (actually ntpath.samefile) 
but  os.sameopenfile is still not implemented.

Looks like it's easy to do: while GetFinalPathNameByHandle already 
accept file handle you can use CRT function _get_osfhandle(fd) to 
convert file descriptors (arguments for sameopenfile) to file handles 
and pass it to GetFinalPathNameByHandle.

For me samefile and sameopenfile has very close semantic and I like to 
see both if it's possible.

This seems entirely reasonable, but I would like to track and tackle
this as a separate issue.
msg96828 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-12-23 02:07
As NTFS supports hard links, I think GetFileInformationByHandle should
be used to compare handles (looking at dwVolumeSerialNumber,
msg96841 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2009-12-23 15:54
That's an excellent idea. I had searched briefly for a more correct solution, but did not find one at the time.
msg111377 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-07-23 19:50
Here's a patch implementing ntpath.sameopenfile with _getfileinformation in Modules/posixmodule.c.

Martin's suggestion is the best way of doing this, which was the basis for _getfileinformation implementation. It returns a tuple of the three relevant fields, and ntpath.sameopenfile compares the results of those tuples for two files and returns the result.
msg115717 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-09-06 17:08
Added in r84561.
Date User Action Args
2022-04-11 14:56:55adminsetgithub: 51815
2010-09-06 17:08:09brian.curtinsetstatus: open -> closed
resolution: fixed
messages: + msg115717

stage: needs patch -> resolved
2010-07-23 19:50:13brian.curtinsetfiles: + issue7566.diff
keywords: + patch
messages: + msg111377
2010-07-23 15:06:25brian.curtinlinkissue8879 dependencies
2010-06-28 00:14:06brian.curtinsetassignee: brian.curtin

nosy: + brian.curtin
stage: needs patch
2010-02-16 18:02:15akrpic77setnosy: + akrpic77

components: - Library (Lib)
versions: - Python 2.7
2010-02-16 03:55:42brian.curtinsetcomponents: + Library (Lib)
versions: + Python 2.7
2009-12-29 12:03:59asvetlovsetnosy: + asvetlov
2009-12-23 16:23:08eric.smithsetnosy: + eric.smith
2009-12-23 15:54:13jaracosetmessages: + msg96841
2009-12-23 02:07:04loewissetnosy: + loewis
messages: + msg96828
2009-12-23 00:56:46jaracocreate