Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
adang1345 opened this issue Nov 8, 2023 · 1 comment
Closed

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

adang1345 opened this issue Nov 8, 2023 · 1 comment
Labels
OS-windows type-bug An unexpected behavior, bug, or error

Comments

@adang1345
Copy link
Contributor

adang1345 commented Nov 8, 2023

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

@adang1345 adang1345 added the type-bug An unexpected behavior, bug, or error label Nov 8, 2023
@zooba zooba closed this as completed Nov 13, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 13, 2023
…tem (pythonGH-112038)

(cherry picked from commit 29af736)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
@zooba
Copy link
Member

zooba commented Nov 13, 2023

Thanks for the report and the fix!

zooba pushed a commit that referenced this issue Nov 13, 2023
…H-112038)

(cherry picked from commit 29af736)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-windows type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants