Skip to content

Jinja2-2.9 and Python3 generate <generator> tag #645

Closed

Description

@tk0miya

With 2.9, 2.9.1 and 2.9.2, Jinja2 generates <generator> tag for macro having blocks.

Example code:

import sys
import jinja2
from jinja2 import Template

template = """
{%- macro hello() %}
  Hello, {% block name %}jinja2{% endblock %}!
{%- endmacro %}
{{ hello() }}
"""

Result:

Python vesion: 3.5.2 (default, Oct 11 2016, 17:23:55)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Jinja2 vesion: 2.9.2

<generator object macro at 0x10ffe2468>

But this works fine on python2.7.

Python vesion: 2.7.13 (default, Dec 20 2016, 13:27:09)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Jinja2 vesion: 2.9.2


  Hello, jinja2!

Note: result of 2.8 and py27, py35.

Python vesion: 2.7.13 (default, Dec 20 2016, 13:27:09)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Jinja2 vesion: 2.8.1


  Hello, jinja2!
Python vesion: 3.5.2 (default, Oct 11 2016, 17:23:55)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Jinja2 vesion: 2.8.1


  Hello, jinja2!

Activity

  1. mitsuhiko commented on Jan 8, 2017

    @mitsuhiko
    Contributor

    What does it even mean to have a {% block %} inside a macro O_O.

  2. added a commit that references this issue on Jan 8, 2017
    6f7fa5c
  3. mitsuhiko commented on Jan 8, 2017

    @mitsuhiko
    Contributor

    It does the same now it did in earlier versions however I'm surprised this does something useful.

  4. cdeil commented on Jan 8, 2017

    @cdeil

    @mitsuhiko - Thanks for fixing it. Could you please make a patch release soon?

    This issue is affecting other Sphinx projects, e.g. the sidebar from the Astropy docs disappeared recently and it took me some time to find this issue:
    astropy/astropy#5679 (comment)
    It's particularly nasty since there's no warning or error from Sphinx, but the generated HTML is corrupted.

  5. mitsuhiko commented on Jan 8, 2017

    @mitsuhiko
    Contributor

    Yes, there will be another one tonight. I just want to see if there is not anything else creeping up.

  6. cdeil commented on Jan 8, 2017

    @cdeil

    Great, thank you!

  7. mitsuhiko commented on Jan 8, 2017

    @mitsuhiko
    Contributor

    Release is out now.

  8. tk0miya commented on Jan 9, 2017

    @tk0miya
    Author

    I confirmed it works fine :-)
    Thank you for quick fix!

  9. locked as resolved and limited conversation to collaborators on Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions