Skip to content

Don't look up the template origin for ignored undefined variables - #1329

Open
patrick-immometrica wants to merge 1 commit into
pytest-dev:mainfrom
patrick-immometrica:template-vars-ignored-origin
Open

patrick-immometrica wants to merge 1 commit into
pytest-dev:mainfrom
patrick-immometrica:template-vars-ignored-origin

Conversation

@patrick-immometrica

Copy link
Copy Markdown

With --fail-on-template-vars, InvalidVarException.__mod__ looks up the template origin with inspect.stack() before it checks whether it should fail at all. In a test marked ignore_template_errors the message is thrown away, but the stack is still inspected for every undefined variable.

A template that renders an undefined variable 2000 times in a loop takes 1.9 s in such a test here, and 0.01 s with this change (also 0.01 s without the flag).

With --fail-on-template-vars the origin is found by inspecting the
stack. That was also done for tests marked ignore_template_errors,
where the message is never used.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant