1. Michael Bayer
  2. mako

Issues

Issue #84 resolved

Caanot use 'dict' builtin in templates

guest
created an issue

In r375 there has been added a patch to allow the use of Python builtin names as template variables. I use the 'dict' builtin in several templates to make a dictionary, but with this patch the compiled template begins with the lines:

from mako import runtime, filters, cache UNDEFINED = runtime.UNDEFINED _magic_number = 2 ...

def render_body(context,pageargs): context.caller_stack._push_frame() try: M_locals = dict(pageargs=pageargs) dict = context.get('dict', UNDEFINED) ...

(ellipsis omitting rest of code)

and, on render time, Python complains with an UnboundLocalError: "local variable 'dict' referenced before assignment" due to the use of dict in the _M_locals line (just before trying to pull from the context).

Regards,

Raúl García

Comments (1)

  1. Log in to comment