From 3797466a856d92468c99d3131317d59500958365 Mon Sep 17 00:00:00 2001 From: gheshm-jpg Date: Wed, 9 Sep 2026 13:35:05 -0400 Subject: [PATCH] ignore file type bits in permission strings --- path/masks.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/path/masks.py b/path/masks.py index 6c551d7..b31337f 100644 --- a/path/masks.py +++ b/path/masks.py @@ -152,6 +152,13 @@ class Permissions(int): 'rwxrw-r--' >>> str(Permissions(0o222)) '-w--w--w-' + + File type bits from stat results do not add permission characters. + + >>> str(Permissions(0o100644)) + 'rw-r--r--' + >>> str(Permissions(0o40755)) + 'rwxr-xr-x' """ @property @@ -162,7 +169,7 @@ def symbolic(self) -> str: @property def bits(self) -> Iterator[int]: - return reversed(tuple(padded(gen_bit_values(self), 0, n=9))) + return reversed(tuple(padded(gen_bit_values(self & 0o777), 0, n=9))) def __str__(self) -> str: return self.symbolic