Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
PowerShell command:
PS D:\cpython> .\PCbuild\build.bat -t CleanAllPS D:\cpython> .\PCbuild\build.bat -e -dPS D:\cpython> .\python.bat -m test -j1Test 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 != 887860239011714428829696The output indicates thattest_attributes failed.
Given thatos.link andos.symlink can both success, Isummarized the test below (may be slightly different from the original), shown in Python code:
importosdefcreate_file(file_name,content=b'content'):withopen(file_name,'xb',0)asfp:fp.write(content)returnfile_nameif__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')forentryinos.scandir('D:\\'):print(entry.name)print(entry.inode())print(os.stat(entry.path,follow_symlinks=False).st_ino)print('')
Output:
$RECYCLE.BIN0121914531583146426630144aspnetcore037170189308524746506240cpython0461777344397171205603328Euler0459231693714999287480320file.txt1828334198897217871282194gobook0458438483719829776760832gobook20458752078369082839138304gopl.io0455523898156183667605504leveldb0445249061707127447355392link_file.txt1828334198897217871282194oceanbase0413631342364789275885568source0121951425071293845733376symlink_dir01057588731233916013248512symlink_file.txt1928334198897217871282195System Volume Information00test-py01057570284489842303696896The above output indicates that:
entry.inode()returns a small integer for a file,0for a folder;os.stat(entry.path, follow_symlinks=False).st_inoreturns a large number, same asfsutil file queryFileIDon 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