From 19751cdf812d434af62bcce79a389f744df4de5e Mon Sep 17 00:00:00 2001 From: Patryk Kaminski Date: Thu, 2 Nov 2023 11:43:25 +0100 Subject: [PATCH] Print backtrace for errors in mako templates Print the exact location of errors in mako templates by printing a full backtrace instead of a stripped output without the file:line information --- scripts/util.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/util.py b/scripts/util.py index a9efed951d..cb855ff51d 100644 --- a/scripts/util.py +++ b/scripts/util.py @@ -1,5 +1,5 @@ """ - Copyright (C) 2022 Intel Corporation + Copyright (C) 2022-2024 Intel Corporation Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT @@ -14,7 +14,7 @@ import json import yaml from mako.template import Template -from mako.exceptions import RichTraceback +from mako import exceptions try: from yaml import CLoader as Loader, CDumper as Dumper except ImportError: @@ -161,13 +161,7 @@ def makoWrite(inpath, outpath, **args): makoFileList.append(outpath) return len(rendered.splitlines()) except: - traceback = RichTraceback() - #for (filename, lineno, function, line) in traceback.traceback: - # print("%s(%s) : error in %s" % (filename, lineno, function)) - # print(line, "\n") - line = "%s: %s" % (str(traceback.error.__class__.__name__), traceback.error) - makoErrorList.append(line) - print(line) + print(exceptions.text_error_template().render()) raise def makoFileListWrite(outpath):