comparison genshi/template/interpolation.py @ 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 f3d998cc941e
children
comparison
equal deleted inserted replaced
989:2d9346a99352 990:8f00b78c6a59
113 yield False, text[pos:offset] 113 yield False, text[pos:offset]
114 pos = offset + 2 114 pos = offset + 2
115 level = 1 115 level = 1
116 while level: 116 while level:
117 match = token_re.match(text, pos) 117 match = token_re.match(text, pos)
118 if match is None: 118 if match is None or not match.group():
119 # if there isn't a match or the match is the empty
120 # string, we're not going to match up braces ever
119 raise TemplateSyntaxError('invalid syntax', filepath, 121 raise TemplateSyntaxError('invalid syntax', filepath,
120 *textpos[1:]) 122 *textpos[1:])
121 pos = match.end() 123 pos = match.end()
122 tstart, tend = match.regs[3] 124 tstart, tend = match.regs[3]
123 token = text[tstart:tend] 125 token = text[tstart:tend]
Copyright (C) 2012-2017 Edgewall Software