Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.9.5: Inheriting from a template containing {{ .. }} fails with a custom Context class #675

ThiefMaster opened this issue Jan 30, 2017 · 0 comments


Copy link

commented Jan 30, 2017

Minimal example:

from jinja2 import DictLoader, Environment
from jinja2.runtime import Context

class MyContext(Context):

class MyEnvironment(Environment):
    context_class = MyContext

loader = DictLoader({'base': '{{ foobar }}',
                     'test': '{% extends "base" %}'})
env = MyEnvironment(loader=loader)
print env.get_template('test').render(foobar='test')


Traceback (most recent call last):
  File "", line 16, in <module>
    print env.get_template('test').render(foobar='test')
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/jinja2/", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/jinja2/", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 1, in top-level template code
  File "<template>", line 1, in top-level template code
TypeError: resolve_or_missing() takes at least 2 arguments (1 given)

As you can see just having a custom Context class, even without changing anything in there, breaks as soon as the base template contains a variable. This is most likely caused by the metaclass added in c6ddeb7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.