提交 5c2c17eb authored 作者: Frédéric Bastien's avatar Frédéric Bastien 提交者: GitHub

Merge pull request #5896 from lamblin/fix_debugmode

Fix more issues in DebugMode
...@@ -270,9 +270,12 @@ class InvalidValueError(DebugModeError): ...@@ -270,9 +270,12 @@ class InvalidValueError(DebugModeError):
Exception: some Op an output value that is inconsistent with Exception: some Op an output value that is inconsistent with
the Type of that output. the Type of that output.
Note: If there is only one parameter and it is a string, then we
will use it as the error message. This is needed when we catch,
extend, and reraise an error.
""" """
def __init__(self, r, v, client_node=None, hint='none', def __init__(self, r, v=None, client_node=None, hint='none',
specific_hint='none'): specific_hint='none'):
super(InvalidValueError, self).__init__() super(InvalidValueError, self).__init__()
self.r = r self.r = r
...@@ -281,7 +284,20 @@ class InvalidValueError(DebugModeError): ...@@ -281,7 +284,20 @@ class InvalidValueError(DebugModeError):
self.hint = hint self.hint = hint
self.specific_hint = specific_hint self.specific_hint = specific_hint
# To allow extending th error message of an existing error.
self.full_err = None
if isinstance(r, str):
assert (v is None and
client_node is None and
hint == 'none' and
specific_hint == 'none')
self.full_err = r
def __str__(self): def __str__(self):
# We have a pre-made message
if getattr(self, 'full_err', None) is not None:
return self.full_err
r, v = self.r, self.v r, v = self.r, self.v
type_r = r.type type_r = r.type
type_v = type(v) type_v = type(v)
......
...@@ -1188,7 +1188,7 @@ class LogicalComparison(BinaryScalarOp): ...@@ -1188,7 +1188,7 @@ class LogicalComparison(BinaryScalarOp):
def __eq__(self, other): def __eq__(self, other):
return (BinaryScalarOp.__eq__(self, other) and return (BinaryScalarOp.__eq__(self, other) and
getattr(self, 'bool', False) == getattr(self, 'bool', False)) getattr(self, 'bool', False) == getattr(other, 'bool', False))
def __hash__(self): def __hash__(self):
# bool should always be True # bool should always be True
...@@ -1220,7 +1220,7 @@ class FixedLogicalComparison(UnaryScalarOp): ...@@ -1220,7 +1220,7 @@ class FixedLogicalComparison(UnaryScalarOp):
def __eq__(self, other): def __eq__(self, other):
return (UnaryScalarOp.__eq__(self, other) and return (UnaryScalarOp.__eq__(self, other) and
getattr(self, 'bool', False) == getattr(self, 'bool', False)) getattr(self, 'bool', False) == getattr(other, 'bool', False))
def __hash__(self): def __hash__(self):
# bool should always be True # bool should always be True
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论