Skip to content

fix: use EAFP try/except for os.getegid/geteuid in stat() (issue #177)#179

Open
Quantum0uasar wants to merge 3 commits into
cloud-custodian:mainfrom
Quantum0uasar:patch-1
Open

fix: use EAFP try/except for os.getegid/geteuid in stat() (issue #177)#179
Quantum0uasar wants to merge 3 commits into
cloud-custodian:mainfrom
Quantum0uasar:patch-1

Conversation

@Quantum0uasar
Copy link
Copy Markdown
Collaborator

Replace LBYL platform check with EAFP try/except AttributeError pattern.

os.getegid() and os.geteuid() are unavailable on Windows and other non-POSIX platforms (e.g. WASI), raising AttributeError. Rather than checking the platform up front, wrap the assignments in a try/except block so group_access and user_access are simply omitted when the underlying OS calls are not available.

Closes #177

…d-custodian#177)

Replace LBYL platform check with EAFP try/except AttributeError pattern.

os.getegid() and os.geteuid() are unavailable on Windows and other
non-POSIX platforms (e.g. WASI), raising AttributeError. Rather than
checking the platform up front, wrap the assignments in a try/except
block so group_access and user_access are simply omitted when the
underlying OS calls are not available.

Closes cloud-custodian#177
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 24, 2026

CLA Not Signed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The __main__.py module breaks under Windows

1 participant