From 302a315ea8769bce68614ed32b1d5dc970455124 Mon Sep 17 00:00:00 2001 From: oliverpool Date: Mon, 29 May 2017 14:35:00 +0200 Subject: [PATCH] fix jinja2 context forbidden modification --- patacrep/songs/chordpro/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index 7f3a88e1..4367d3ef 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -91,8 +91,10 @@ class ChordproSong(Song): @contextfunction def _render_ast(context, content): """Render ``content``.""" - context.vars['content'] = content - return context.environment.get_template(content.template()).render(context) + # context is readonly: create a copy before overriding the 'content' key + new_context = context.get_all().copy() + new_context['content'] = content + return context.environment.get_template(content.template()).render(new_context) def _escape_specials(self, content, chars=None, *, translation_map=None): if translation_map is None: