Closed
Description
Bug report
Bug description:
PowerShell command:
PS D:\cpython> .\PCbuild\build.bat -t CleanAll
PS D:\cpython> .\PCbuild\build.bat -e -d
PS D:\cpython> .\python.bat -m test -j1
Test output:
0:26:00 load avg: 0.52 [285/469/2] test_os failed (1 failure)
test test_os failed -- Traceback (most recent call last):
File "D:\cpython\Lib\test\test_os.py", line 4696, in test_attributes
self.check_entry(entry, 'dir', True, False, False)
File "D:\cpython\Lib\test\test_os.py", line 4645, in check_entry
self.assertEqual(entry.inode(),
AssertionError: 0 != 887860239011714428829696
The output indicates that test_attributes
failed.
Given that os.link
and os.symlink
can both success, I summarized the test below (may be slightly different from the original), shown in Python code:
import os
def create_file(file_name, content=b'content'):
with open(file_name, 'xb', 0) as fp:
fp.write(content)
return file_name
if __name__ == '__main__':
dirname = 'D:\\test-py'
os.mkdir(dirname)
filename = create_file('D:\\file.txt')
os.link(filename, 'D:\\link_file.txt')
os.symlink(dirname, 'D:\\symlink_dir', True)
os.symlink(filename, 'D:\\symlink_file.txt')
for entry in os.scandir('D:\\'):
print(entry.name)
print(entry.inode())
print(os.stat(entry.path, follow_symlinks=False).st_ino)
print('')
Output:
$RECYCLE.BIN
0
121914531583146426630144
aspnetcore
0
37170189308524746506240
cpython
0
461777344397171205603328
Euler
0
459231693714999287480320
file.txt
18
28334198897217871282194
gobook
0
458438483719829776760832
gobook2
0
458752078369082839138304
gopl.io
0
455523898156183667605504
leveldb
0
445249061707127447355392
link_file.txt
18
28334198897217871282194
oceanbase
0
413631342364789275885568
source
0
121951425071293845733376
symlink_dir
0
1057588731233916013248512
symlink_file.txt
19
28334198897217871282195
System Volume Information
0
0
test-py
0
1057570284489842303696896
The above output indicates that:
entry.inode()
returns a small integer for a file,0
for a folder;os.stat(entry.path, follow_symlinks=False).st_ino
returns a large number, same asfsutil file queryFileID
on Windows
Because they are different, the test fails.
Note: This issue will not appear on NTFS. This issue can only be reproduced on ReFS.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows