Skip to content

os.fstat() fails on FAT32 file system on Windows #111856

Closed
@adang1345

Description

@adang1345

Bug report

Bug description:

This is Python 3.12.0 x64 running on Windows 11. On a FAT32 drive, I have a file f.txt.

>>> import os
>>> os.stat('f.txt')
os.stat_result(st_mode=33206, st_ino=4194560, st_dev=1589430838, st_nlink=1, st_uid=0, st_gid=0, st_size=0, st_atime=1699419600, st_mtime=1699459266, st_ctime=1699459265)
>>> f = open('f.txt','rb')
>>> f.fileno()
3
>>> os.fstat(f.fileno())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [WinError 87] The parameter is incorrect

This error does not occur with Python 3.11.6. I suspect that the issue was introduced with #102149. 6031727 provided a fix for os.stat(), but it seems that an equivalent bug exists for os.fstat().

I believe the fix would involve changing the line https://github.com/python/cpython/blob/74b868f636a8af9e5540e3315de666500147d47a/Python/fileutils.c#L1275C48-L1275C48 to account for the possibility that the file system does not support FileIdInfo.

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowstype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions