提交 accb6776 authored 作者: Frederic Bastien's avatar Frederic Bastien

Fix python 3 different dict handling

上级 fb483a78
...@@ -51,12 +51,13 @@ class MissingInputError(Exception): ...@@ -51,12 +51,13 @@ class MissingInputError(Exception):
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
if kwargs: if kwargs:
assert kwargs.keys() == ["variable"] # The call to list is needed for Python 3
tr = getattr(kwargs.values()[0].tag, 'trace', []) assert list(kwargs.keys()) == ["variable"]
tr = getattr(list(kwargs.values())[0].tag, 'trace', [])
if type(tr) is list and len(tr) > 0: if type(tr) is list and len(tr) > 0:
sio = StringIO() sio = StringIO()
print("\nBacktrace when the variable is created:", file=sio) print("\nBacktrace when the variable is created:", file=sio)
for subtr in kwargs.values()[0].tag.trace: for subtr in list(kwargs.values())[0].tag.trace:
traceback.print_list(subtr, sio) traceback.print_list(subtr, sio)
args = args + (str(sio.getvalue()),) 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
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论