@ -119,12 +119,12 @@ class InterpreterObject:
# We use `type(...) == type(...)` here to enforce an *exact* match for comparison. We
# 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))`
# 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`
# would pass because this comparison must never be true: `derived_obj == base_obj`
if type ( self ) != type ( other ) :
if type ( self ) is not type ( other ) :
self . _throw_comp_exception ( other , ' == ' )
self . _throw_comp_exception ( other , ' == ' )
return self == other
return self == other
def op_not_equals ( self , other : TYPE_var ) - > bool :
def op_not_equals ( self , other : TYPE_var ) - > bool :
if type ( self ) != type ( other ) :
if type ( self ) is not type ( other ) :
self . _throw_comp_exception ( other , ' != ' )
self . _throw_comp_exception ( other , ' != ' )
return self != other
return self != other
@ -157,12 +157,12 @@ class ObjectHolder(InterpreterObject, T.Generic[InterpreterObjectTypeVar]):
# Override default comparison operators for the held object
# Override default comparison operators for the held object
def op_equals ( self , other : TYPE_var ) - > bool :
def op_equals ( self , other : TYPE_var ) - > bool :
# See the comment from InterpreterObject why we are using `type()` here.
# See the comment from InterpreterObject why we are using `type()` here.
if type ( self . held_object ) != type ( other ) :
if type ( self . held_object ) is not type ( other ) :
self . _throw_comp_exception ( other , ' == ' )
self . _throw_comp_exception ( other , ' == ' )
return self . held_object == other
return self . held_object == other
def op_not_equals ( self , other : TYPE_var ) - > bool :
def op_not_equals ( self , other : TYPE_var ) - > bool :
if type ( self . held_object ) != type ( other ) :
if type ( self . held_object ) is not type ( other ) :
self . _throw_comp_exception ( other , ' != ' )
self . _throw_comp_exception ( other , ' != ' )
return self . held_object != other
return self . held_object != other