Closed
Labels
Description
The project in question: https://github.com/mgedmin/project-summary.
A week ago it was building fine, and today I got an email from GitHub Actions telling me about build failures. I've narrowed down the cause to a mako version change: 1.3.7 breaks my test suite, 1.3.6 works fine. The errors look like this:
summary.py:1027: in stylesheet_rules
Template(rule, default_filters=['str', 'n']).render_unicode(
.tox/py312/lib/python3.12/site-packages/mako/template.py:443: in render_unicode
return runtime._render(
.tox/py312/lib/python3.12/site-packages/mako/runtime.py:874: in _render
_render_context(
.tox/py312/lib/python3.12/site-packages/mako/runtime.py:916: in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
.tox/py312/lib/python3.12/site-packages/mako/runtime.py:938: in _exec_template
_render_error(template, context, compat.exception_as())
.tox/py312/lib/python3.12/site-packages/mako/runtime.py:948: in _render_error
result = template.error_handler(context, error)
.tox/py312/lib/python3.12/site-packages/mako/runtime.py:936: in _exec_template
callable_(context, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = <mako.runtime.Context object at 0x718d12ba4410>
pageargs = {'column': <summary.DateColumn object at 0x718d12ba7e00>, 'css_class': 'date', 'discrim': '.date', 'page': <summary.Page object at 0x718d12b9e060>}, __M_caller = None
__M_locals = {'pageargs': {'column': <summary.DateColumn object at 0x718d12ba7e00>, 'css_class': 'date', 'discrim': '.date', 'page': <summary.Page object at 0x718d12b9e060>}}
column = <summary.DateColumn object at 0x718d12ba7e00>, page = <summary.Page object at 0x718d12b9e060>, css_class = 'date'
__M_writer = <built-in method append of collections.deque object at 0x718d12b5d120>
def render_body(context,**pageargs):
__M_caller = context.caller_stack._push_frame()
try:
__M_locals = __M_dict_builtin(pageargs=pageargs)
try:
column = context['column']
except KeyError:
raise NameError("'column' is not defined")
try:
page = context['page']
except KeyError:
raise NameError("'page' is not defined")
try:
css_class = context['css_class']
except KeyError:
raise NameError("'css_class' is not defined")
__M_writer = context.writer()
if column.align:
__M_writer(' #')
> __M_writer(n(str(page.name)))
# memory:0x718d12b9d220 line 2 in render_body:
# #${page.name} th.${css_class},
__M_writer(' th.')
__M_writer(n(str(css_class)))
E NameError: name 'n' is not defined
memory:0x718d12b9d220:34: NameError
I'm rendering the template using
def Template(*args, **kw) -> mako.template.Template:
kw.setdefault('default_filters', ['h'])
return mako.template.Template(error_handler=mako_error_handler,
strict_undefined=True,
*args, **kw)
...
Template(rule, default_filters=['str', 'n']).render_unicode(
page=page,
column=self,
css_class=self.css_class,
discrim=discrim,
)Is this missing something?
This is probably related to the fix for #140, but I don't understand that issue nor what I'm doing wrong here. The release notes are also not very helpful.
Activity
zzzeek commentedon Dec 7, 2024
with Mako I am just reverting these fixes, since they cannot predict real world cases, which here we will add and see if the contributor @cocolato wants to try again.
the issue is that use of the default filter names has inconsistent behavior vs names that are not default filters.
zzzeek commentedon Dec 7, 2024
I need to have an MCVE. Can you show me the arguments to make this script fail?
zzzeek commentedon Dec 7, 2024
this does it
sqla-tester commentedon Dec 7, 2024
Mike Bayer has proposed a fix for this issue in the main branch:
Revert "Support passing custom filters with the same name as built-in flags" https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5579
zzzeek commentedon Dec 7, 2024
1.3.7 is yanked
zzzeek commentedon Dec 7, 2024
1.3.8 is released
mgedmin commentedon Dec 7, 2024
Wow that was fast. Thank you!
Revert "Support passing custom filters with the same name as built-in…