diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-08-29 13:08:20 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-08-31 23:01:21 +0200 |
commit | 8d92e6d865e2a03875c29d2e2aa131ce774a5d5d (patch) | |
tree | 7d614e505c7a35ae08ea97eadfe77400f1fa3cca /mesonbuild/interpreterbase/baseobjects.py | |
parent | 86f70c873a46c63e7a6e12de562ad8c907eabbc5 (diff) | |
download | meson-8d92e6d865e2a03875c29d2e2aa131ce774a5d5d.zip meson-8d92e6d865e2a03875c29d2e2aa131ce774a5d5d.tar.gz meson-8d92e6d865e2a03875c29d2e2aa131ce774a5d5d.tar.bz2 |
interpreter: Add IntegerHolder
Diffstat (limited to 'mesonbuild/interpreterbase/baseobjects.py')
-rw-r--r-- | mesonbuild/interpreterbase/baseobjects.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mesonbuild/interpreterbase/baseobjects.py b/mesonbuild/interpreterbase/baseobjects.py index b28654a..4b538fb 100644 --- a/mesonbuild/interpreterbase/baseobjects.py +++ b/mesonbuild/interpreterbase/baseobjects.py @@ -111,6 +111,9 @@ class InterpreterObject: )) def op_equals(self, other: TYPE_var) -> bool: + # We use `type(...) == type(...)` here to enforce an *exact* match for comparison. We + # don't want comparisons to be possible where `isinstance(derived_obj, type(base_obj))` + # would pass because this comparison must never be true: `derived_obj == base_obj` if type(self) != type(other): self._throw_comp_exception(other, '==') return self == other @@ -148,6 +151,7 @@ class ObjectHolder(InterpreterObject, T.Generic[InterpreterObjectTypeVar]): # Override default comparison operators for the held object def op_equals(self, other: TYPE_var) -> bool: + # See the comment from InterpreterObject why we are using `type()` here. if type(self.held_object) != type(other): self._throw_comp_exception(other, '==') return self.held_object == other |