提交 57756a29 authored 作者: Frederic Bastien's avatar Frederic Bastien

Have the error printed only once.

上级 36c2ee9b
...@@ -52,13 +52,9 @@ class MissingInputError(Exception): ...@@ -52,13 +52,9 @@ class MissingInputError(Exception):
if kwargs: if kwargs:
# The call to list is needed for Python 3 # The call to list is needed for Python 3
assert list(kwargs.keys()) == ["variable"] assert list(kwargs.keys()) == ["variable"]
tr = getattr(list(kwargs.values())[0].tag, 'trace', []) error_msg = get_variable_trace_string(kwargs["variable"])
if isinstance(tr, list) and len(tr) > 0: if error_msg:
sio = StringIO() args = args + (error_msg,)
print("\nBacktrace when the variable is created:", file=sio)
for subtr in list(kwargs.values())[0].tag.trace:
traceback.print_list(subtr, sio)
args = args + (str(sio.getvalue()),)
s = '\n'.join(args) # Needed to have the new line print correctly s = '\n'.join(args) # Needed to have the new line print correctly
Exception.__init__(self, s) Exception.__init__(self, s)
...@@ -393,7 +389,6 @@ class FunctionGraph(utils.object2): ...@@ -393,7 +389,6 @@ class FunctionGraph(utils.object2):
"Theano flag exception_verbosity='high', " "Theano flag exception_verbosity='high', "
"for more information on this error." "for more information on this error."
% (node.inputs.index(r), str(node))) % (node.inputs.index(r), str(node)))
error_msg += get_variable_trace_string(r)
raise MissingInputError(error_msg, variable=r) raise MissingInputError(error_msg, variable=r)
for node in new_nodes: for node in new_nodes:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论