aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker-Weissmann <39418860+Volker-Weissmann@users.noreply.github.com>2021-02-01 18:48:48 +0100
committerGitHub <noreply@github.com>2021-02-01 09:48:48 -0800
commitf31ffaaf1754e4578127049844c14eba6bdda477 (patch)
tree1c8a2d065f47494ef5aab0944b186a1025b2d52a
parent127b7886286c21df528121b2ec3a2e24ea8874d0 (diff)
downloadmeson-f31ffaaf1754e4578127049844c14eba6bdda477.zip
meson-f31ffaaf1754e4578127049844c14eba6bdda477.tar.gz
meson-f31ffaaf1754e4578127049844c14eba6bdda477.tar.bz2
bugfix concerning octal umasks (#8282)
* bugfix concerning octal umasks * minor fix * spelling mistake
-rw-r--r--mesonbuild/coredata.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 211efec..a4ce965 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -144,7 +144,14 @@ class UserIntegerOption(UserOption[int]):
except ValueError:
raise MesonException('Value string "%s" is not convertible to an integer.' % valuestring)
-class UserUmaskOption(UserIntegerOption, UserOption[T.Union[str, int]]):
+class OctalInt(int):
+ # NinjaBackend.get_user_option_args uses str() to converts it to a command line option
+ # UserUmaskOption.toint() uses int(str, 8) to convert it to an integer
+ # So we need to use oct instead of dec here if we do not want values to be misinterpreted.
+ def __str__(self):
+ return oct(int(self))
+
+class UserUmaskOption(UserIntegerOption, UserOption[T.Union[str, OctalInt]]):
def __init__(self, description: str, value: T.Any, yielding: T.Optional[bool] = None):
super().__init__(description, (0, 0o777, value), yielding)
self.choices = ['preserve', '0000-0777']
@@ -154,12 +161,12 @@ class UserUmaskOption(UserIntegerOption, UserOption[T.Union[str, int]]):
return self.value
return format(self.value, '04o')
- def validate_value(self, value: T.Any) -> T.Union[str, int]:
+ def validate_value(self, value: T.Any) -> T.Union[str, OctalInt]:
if value is None or value == 'preserve':
return 'preserve'
- return super().validate_value(value)
+ return OctalInt(super().validate_value(value))
- def toint(self, valuestring: T.Union[str, int]) -> int:
+ def toint(self, valuestring: T.Union[str, OctalInt]) -> int:
try:
return int(valuestring, 8)
except ValueError as e: