Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Find the #encoding directive even if it's after a comment (for example)

Added a test and applied Juan's patch, everything seems to check out
alright with it

Reported-by: Juan Fiol <fiolj@yahoo.com>
  • Loading branch information...
commit 5d931545fcde3029a5e4f49d9d72533c0bd0f667 1 parent 46df95c
@rtyler rtyler authored
Showing with 7 additions and 1 deletion.
  1. +1 −1  cheetah/Compiler.py
  2. +6 −0 cheetah/Tests/SyntaxAndOutput.py
View
2  cheetah/Compiler.py
@@ -1556,7 +1556,7 @@ def __init__(self, source=None, file=None,
else:
unicodeMatch = unicodeDirectiveRE.search(source)
- encodingMatch = encodingDirectiveRE.match(source)
+ encodingMatch = encodingDirectiveRE.search(source)
if unicodeMatch:
if encodingMatch:
raise ParseError(
View
6 cheetah/Tests/SyntaxAndOutput.py
@@ -742,6 +742,12 @@ def test5(self):
self.verify("#encoding latin-1\nAndr\202",
u'Andr\202')
+ def test6(self):
+ '''Using #encoding on the second line'''
+ self.verify("""### Comments on the first line
+#encoding utf-8\n\xe1\x88\xb4""",
+ u'\u1234', outputEncoding='utf8')
+
class UnicodeDirective(OutputTest):
def test1(self):
"""basic #unicode """
Please sign in to comment.
Something went wrong with that request. Please try again.