How to troubleshoot/debug what line of mako file cause python exception to raise? #425
-
I'm getting a python TypeError raised when elaborating a .mako file but the Traceback does not tell me what line of the mako file cause it. It looks like this: Traceback (most recent call last):
File "foo.py", line NN, in elaborate_template
return my_template.render(var=value)
File ".../python3.10/site-packages/mako/template.py", line 438, in render
return runtime._render(self, self.callable_, args, data)
File ".../python3.10/site-packages/mako/runtime.py", line 874, in _render
_render_context(
File ".../python3.10/site-packages/mako/runtime.py", line 916, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File ".../python3.10/site-packages/mako/runtime.py", line 943, in _exec_template
callable_(context, *args, **kwargs)
File "memory:0x7ca7deb88130", line 606, in render_body
File "bar.py", line MM, in __eq__
raise TypeError("Comparison not supported")
TypeError: Comparison not supported Code at my_template = Template(template_file.read())
return my_template.render(var=value) Environment:
Background:I was changing external python in
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
sure! put a print statement in your mako template inside of a <% %> section. it's just python
also sure! use the Python breakpoint() statement, again inside of a <% %> section, will bring you right there. additionally you can look at the actual Python module (a .py script) that Mako generates, do a |
Beta Was this translation helpful? Give feedback.
use format_exceptions, see https://docs.makotemplates.org/en/latest/usage.html#handling-exceptions