changeset 990:8f00b78c6a59 trunk

Stop try to lex for matching braces in interpolation if the token_re matches an empty string. This fixes the infinite loop triggered by the test suite as a result of the change to Python 2.7 describe in http://bugs.python.org/issue16152 and reported in http://genshi.edgewall.org/ticket/540.
author hodgestar
date Sat, 26 Jan 2013 11:53:36 +0000
parents 2d9346a99352
children 16ccaf7389d5
files genshi/template/interpolation.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/genshi/template/interpolation.py
+++ b/genshi/template/interpolation.py
@@ -115,7 +115,9 @@
             level = 1
             while level:
                 match = token_re.match(text, pos)
-                if match is None:
+                if match is None or not match.group():
+                    # if there isn't a match or the match is the empty
+                    # string, we're not going to match up braces ever
                     raise TemplateSyntaxError('invalid syntax',  filepath,
                                               *textpos[1:])
                 pos = match.end()
Copyright (C) 2012-2017 Edgewall Software