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

Fix tokens line number calculation when whitespace stripping is used #1178

merged 1 commit into from Mar 30, 2020


Copy link

@avli avli commented Mar 27, 2020

The current version seems to assign wrong line numbers to tokens when whitespace trimming is used. For example this code:

from jinja2 import Environment

if __name__ == '__main__':
    env = Environment()
    tmpl = env.from_string(
{%- block content -%}
    {{ item }}
{% endblock %}

prints [(2, 12), (4, 23)] when it should be [(3, 12), (5, 23)]. In particular, this causes troubles for debuggers (see here).

The suggested patch attempts to fix the line number calculation. Please let me know if I have missed something. Thanks in advance!

@davidism davidism changed the base branch from master to 2.11.x Mar 30, 2020
@davidism davidism added this to the 2.11.2 milestone Mar 30, 2020
@davidism davidism merged commit 5f95471 into pallets:2.11.x Mar 30, 2020
11 checks passed
Copy link

@davidism davidism commented Mar 30, 2020

Thanks for the fix! This will be in 2.11.2.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants