Skip to content

gh-126253: Ignore unknown Windows file attribute bits in scandir test - #156305

Open
Wanbinyu wants to merge 1 commit into
python:mainfrom
Wanbinyu:gh-126253-test-os-file-attributes
Open

gh-126253: Ignore unknown Windows file attribute bits in scandir test#156305
Wanbinyu wants to merge 1 commit into
python:mainfrom
Wanbinyu:gh-126253-test-os-file-attributes

Conversation

@Wanbinyu

@Wanbinyu Wanbinyu commented Aug 24, 2026

Copy link
Copy Markdown

Closes #126253.

os.scandir().stat() and os.stat() can return different values for st_file_attributes when NTFS reports bits that are not exposed by Python's stat module. Limit the scandir test comparison to the public stat.FILE_ATTRIBUTE_* bits, while continuing to compare every public bit strictly.

The regression test constructs os.stat_result values with the reported 0x10000000 bit so the behavior is covered even on Windows builds where the filesystem does not naturally return it. It also verifies that a difference in FILE_ATTRIBUTE_READONLY still fails the comparison.

Tests:

  • PCbuild\amd64\python_d.exe -m test test_os.test_os -m "*attributes*" -v
  • PCbuild\amd64\python_d.exe -m test -v test_os
  • PCbuild\amd64\python_d.exe Tools\patchcheck\patchcheck.py

This contribution was prepared with assistance from OpenAI Codex. I reviewed and tested the resulting changes.

@python-cla-bot

python-cla-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Aug 24, 2026
@bedevere-app

bedevere-app Bot commented Aug 24, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_os.test_attributes() fails on Windows

1 participant