You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Windows there's a platform-specific failure exposed by tests/test_main.py::test_stat_good because os.getegid() is not available on Windows.
Alter the __main__.py to have a Windows-compatible variant of the stat() function without the group_access and user_access attributes of the data object it builds.
Thanks for the feedback @slott56! You're right — using sys.platform (or platform.system()) is fragile.
@Rohan5commit please update PR #178 to use a try/except AttributeError block instead, which is more robust and idiomatic:
try:
data["group_access"] =celtypes.BoolType(status.st_gid==os.getegid()) # type: ignore[attr-defined]data["user_access"] =celtypes.BoolType(status.st_uid==os.geteuid()) # type: ignore[attr-defined]exceptAttributeError:
pass# os.getegid() and os.geteuid() are not available on all platforms (e.g. Windows)
Also remove import platform and the _IS_WINDOWS flag entirely — they are no longer needed. This approach handles any platform where those attributes are missing, not just Windows.
Activity
Quantum0uasar commentedon May 21, 2026
Hi! I'd be happy to work on this fix.
The issue is that
os.getegid()(andos.getuid()/os.getgid()if used similarly) is a Unix-only call and raisesAttributeErroron Windows.My plan:
group_accessanduser_accesscalls in a platform check:if hasattr(os, 'getegid')(orif sys.platform != 'win32')tests/test_main.pyto handle both platformsThis should be a minimal, targeted fix. I'll open a draft PR shortly — let me know if you have a preference on how the Windows fallback should behave!
fix: make stat() Windows-compatible by guarding os.getegid/geteuid
slott56 commentedon May 21, 2026
Sorry for not seeing this before the PR was submitted.
An
ifusingsys.platformis not the best approach. The use ofhasattr()or atry/exceptblock is going to work out more consistently across more OS's. See the https://docs.python.org/3/library/intro.html#notes-on-availability which is rather vague.Quantum0uasar commentedon May 21, 2026
Thanks for the feedback @slott56! You're right — using
sys.platform(orplatform.system()) is fragile.@Rohan5commit please update PR #178 to use a
try/except AttributeErrorblock instead, which is more robust and idiomatic:Also remove
import platformand the_IS_WINDOWSflag entirely — they are no longer needed. This approach handles any platform where those attributes are missing, not just Windows.fix: use EAFP try/except for os.getegid/geteuid in stat() (issue clou…