diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-06-14 15:36:17 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-06-22 09:13:41 -0700 |
commit | 132420a05901deb8be5524c17fde7031d5d9b8a1 (patch) | |
tree | 9871049ec6170c576a44f0e131361a601f15ec85 | |
parent | d636b92c1adc1588ff11b6ee4972c4bdd686f433 (diff) | |
download | meson-132420a05901deb8be5524c17fde7031d5d9b8a1.zip meson-132420a05901deb8be5524c17fde7031d5d9b8a1.tar.gz meson-132420a05901deb8be5524c17fde7031d5d9b8a1.tar.bz2 |
minstall: make intentions clearer
The existing code works, but it probably doesn't do what the author
thought it would do. `(x or y or z) is not None` works by checking that
each of those things are *truthy* in turn, and returning the first
truthy value, which is compared against None. Using `all()` makes it
very clear that what you want to do is make sure that each value is not
None.
-rw-r--r-- | mesonbuild/minstall.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index 9bb5ba7..7011c42 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -183,12 +183,12 @@ def sanitize_permissions(path: str, umask: T.Union[str, int]) -> None: def set_mode(path: str, mode: T.Optional['FileMode'], default_umask: T.Union[str, int]) -> None: - if mode is None or (mode.perms_s or mode.owner or mode.group) is None: + if mode is None or all(m is None for m in [mode.perms_s, mode.owner, mode.group]): # Just sanitize permissions with the default umask sanitize_permissions(path, default_umask) return # No chown() on Windows, and must set one of owner/group - if not is_windows() and (mode.owner or mode.group) is not None: + if not is_windows() and (mode.owner is not None or mode.group is not None): try: set_chown(path, mode.owner, mode.group, follow_symlinks=False) except PermissionError as e: |