from mako.template import Template
from mako.lookup import TemplateLookup
from mako import exceptions
from mako.exceptions import RichTraceback
def run():
try:
s = """
Atomic(ss[2], operand.z);
Atomic(ss[2], operand.z);
Atomic(ss[2], operand.z);
Atomic(ss[2], operand.z);
"""
t = Template(s)
print(t.source)
except:
traceback = RichTraceback()
for (filename, lineno, function, line) in traceback.traceback:
print("File %s, line %s, in %s" % (filename, lineno, function))
print(line, "\n")
print("%s: %s" % (str(traceback.error.__class__.__name__), traceback.error))
if __name__ == "__main__":
run()
エラー:
t = Template(s)
File /usr/lib/python3/dist-packages/mako/template.py, line 273, in __init__
(code, module) = _compile_text(self, text, filename)
File /usr/lib/python3/dist-packages/mako/template.py, line 615, in _compile_text
generate_magic_comment=template.disable_unicode)
File /usr/lib/python3/dist-packages/mako/template.py, line 597, in _compile
node = lexer.parse()
File /usr/lib/python3/dist-packages/mako/lexer.py, line 248, in parse
raise exceptions.CompileException("assertion failed")
TypeError: __init__() missing 4 required positional arguments: 'source', 'lineno', 'pos', and 'filename'