Message387656
| Author |
eryksun |
| Recipients |
eryksun, jkloth, paul.moore, steve.dower, tim.golden, vstinner, zach.ware |
| Date |
2021年02月25日.10:24:57 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1614248698.21.0.255569912483.issue26658@roundup.psfhosted.org> |
| In-reply-to |
| Content |
os.stat() was redesigned in issue 37834, which entailed extensive updates across the standard library to improve support for Windows reparse points. As part of this, Win32JunctionTests.tearDown() was changed to use a more reliable lexists() check, which resolves this issue.
FYI, the new implementation of os.stat() supports an ImDisk virtual disk (v2.0.9 from 2015-12). In the following example, "junctest" is a mountpoint (junction) in an NTFS filesystem. The filesystem is mounted on an ImDisk device, as seen its VOLUME_NAME_NT (2) path:
>>> flags = win32file.FILE_FLAG_OPEN_REPARSE_POINT
>>> flags |= win32file.FILE_FLAG_BACKUP_SEMANTICS
>>> h = win32file.CreateFile('junctest', 0, 0, None, 3, flags, None)
>>> win32file.GetFinalPathNameByHandle(h, 2)
'\\Device\\ImDisk0\\junctest'
stat() traverses the mountpoint:
>>> os.stat('junctest').st_reparse_tag == 0
True
lstat() opens the mountpoint:
>>> os.lstat('junctest').st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT
True
This version of Imdisk doesn't support the mountpoint manager, so trying to get the VOLUME_NAME_DOS (0) name of r"\Device\ImDisk0" (e.g. r"\\?\R:") still fails the same as before:
>>> win32file.GetFinalPathNameByHandle(h, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pywintypes.error: (1, 'GetFinalPathNameByHandle', 'Incorrect function.')
But os.stat() no longer needs it. |
|