Skip to content

Broken on Python 3 with a custom template #47

@dstufft

Description

@dstufft

Trying to use a custom template on Python 3.x results in:

Loading template...
Finding news fragments...
Rendering news fragments...
Traceback (most recent call last):
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/bin/towncrier", line 11, in <module>
    sys.exit(_main())
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/towncrier/__init__.py", line 36, in _main
    return __main(draft, directory, project_version, project_date)
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/towncrier/__init__.py", line 74, in __main
    rendered = render_fragments(template, fragments, definitions)
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/towncrier/_builder.py", line 101, in render_fragments
    jinja_template = Template(template, trim_blocks=True)
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/jinja2/environment.py", line 945, in __new__
    return env.from_string(source, template_class=cls)
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/jinja2/environment.py", line 880, in from_string
    return cls.from_code(self, self.compile(source), globals, None)
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/jinja2/environment.py", line 581, in compile
    defer_init=defer_init)
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/jinja2/environment.py", line 543, in _generate
    optimized=self.optimized)
  File "/Users/dstufft/.virtualenvs/tmp-46f4170e7667d3a/lib/python3.6/site-packages/jinja2/compiler.py", line 78, in generate
    raise TypeError('Can\'t compile non template nodes')
TypeError: Can't compile non template nodes

It appears this is because the template is being read as bytes instead of a string.

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