Skip to content

How to troubleshoot/debug what line of mako file cause python exception to raise? #424

Description

@kaddkaka

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 foo.py

my_template = Template(template_file.read())
return my_template.render(var=value)

Environment:

  • python verstion 3.10.15
  • mako.__version__ = 1.3.5

Background:

I was changing external python in bar.py and have never had to modify a mako file before. I couldn't find anything in Discussions or Issues when searching for Troubleshoot/Debug/Exception. So any help appreciated.

  1. Is it possible to print() from inside the .mako so that it appears on stdout while rendering?
  2. Can I step through the render process with debugger somehow?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions