Skip to content

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

Merged
vstinner merged 8 commits into
python:mainfrom
Wanbinyu:gh-126253-test-os-file-attributes
Nov 12, 2026
Merged

vstinner merged 8 commits into
python:mainfrom
Wanbinyu:gh-126253-test-os-file-attributes

Conversation

@Wanbinyu

@Wanbinyu Wanbinyu commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

For #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.

@hugovk

This comment was marked as resolved.

@hugovk

This comment was marked as resolved.

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @hugovk for commit 744f998 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F156305%2Fmerge

The command will test the builders whose names match following regular expression: ARM64 Windows( Non-Debug)? PR

The builders matched are:

  • ARM64 Windows Non-Debug PR
  • ARM64 Windows PR

Comment thread Lib/test/test_os/test_os.py Resolved
Comment thread Lib/test/test_os/test_os.py Resolved
Comment thread Lib/test/test_os/test_os.py Resolved
Comment thread Lib/test/test_os/test_os.py Resolved
Comment thread Lib/test/test_os/test_os.py Resolved
Comment thread Lib/test/test_os/test_os.py Resolved
hugovk and others added 4 commits November 12, 2026 16:04
… NEWS

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@hugovk

hugovk commented Nov 12, 2026

Copy link
Copy Markdown
Member

!buildbot ARM64 Windows( Non-Debug)? PR

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @hugovk for commit 6928e67 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F156305%2Fmerge

The command will test the builders whose names match following regular expression: ARM64 Windows( Non-Debug)? PR

The builders matched are:

  • ARM64 Windows Non-Debug PR
  • ARM64 Windows PR

@hugovk

hugovk commented Nov 12, 2026

Copy link
Copy Markdown
Member

I applied the suggested changes, and buildbots passed.

@vstinner @zware Please review, thanks!

Comment thread Lib/test/test_os/test_os.py Resolved

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I pushed a change to add a comment on FILE_ATTRIBUTE_MASK.

@vstinner
vstinner enabled auto-merge (squash) November 12, 2026 17:40
@vstinner

Copy link
Copy Markdown
Member

Let me enable auto-merge, #126253 issue is failing for several days on ARM64 Windows buildbots, it's quite annoying.

@vstinner vstinner added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 12, 2026
@vstinner

Copy link
Copy Markdown
Member

#126253 fails also on 3.14 and 3.15 buildbots, so I enabled backport to these branches.

@@ -0,0 +1 @@
Fix ``test_os.test_attributes()`` on Windows NTFS: ignore unknown file attributes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced this needs a NEWS entry at all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue #126253 is failing for at least 2 years, IMO it's ok to document the fix. At the beginning, the NEWS entry was way longer, Hugo rewrote it to make it shorter.

Anyway, your comment was posted after I enabled auto-merge and the change was just merged with the NEWS entry in the meanwhile. Sorry! So I will just backport it as it is.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(My shortening was applying Victor's suggestion :)

@vstinner
vstinner merged commit 2087658 into python:main Nov 12, 2026
62 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @Wanbinyu for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Nov 12, 2026

Copy link
Copy Markdown

GH-161899 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 12, 2026
@bedevere-app

bedevere-app Bot commented Nov 12, 2026

Copy link
Copy Markdown

GH-161900 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 12, 2026
@vstinner

Copy link
Copy Markdown
Member

Thanks @Wanbinyu for the initial fix and thanks @hugovk for the cleanup!

vstinner added a commit that referenced this pull request Nov 12, 2026
…H-156305) (#161900)

gh-126253: Ignore unknown Windows file attributes in test_os (GH-156305)
(cherry picked from commit 2087658)

Co-authored-by: 万彬宇 <3431359639@qq.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this pull request Nov 12, 2026
…H-156305) (#161899)

gh-126253: Ignore unknown Windows file attributes in test_os (GH-156305)
(cherry picked from commit 2087658)

Co-authored-by: 万彬宇 <3431359639@qq.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner vstinner added the needs backport to 3.13 only security fixes label Nov 15, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @Wanbinyu for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Nov 15, 2026

Copy link
Copy Markdown

GH-162043 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants