summaryrefslogtreecommitdiff
path: root/cheetah
diff options
context:
space:
mode:
Diffstat (limited to 'cheetah')
-rw-r--r--cheetah/Compiler.py2
-rw-r--r--cheetah/Tests/SyntaxAndOutput.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/cheetah/Compiler.py b/cheetah/Compiler.py
index f4c7668..ee55868 100644
--- a/cheetah/Compiler.py
+++ b/cheetah/Compiler.py
@@ -1556,7 +1556,7 @@ class ModuleCompiler(SettingsManager, GenUtils):
else:
unicodeMatch = unicodeDirectiveRE.search(source)
- encodingMatch = encodingDirectiveRE.match(source)
+ encodingMatch = encodingDirectiveRE.search(source)
if unicodeMatch:
if encodingMatch:
raise ParseError(
diff --git a/cheetah/Tests/SyntaxAndOutput.py b/cheetah/Tests/SyntaxAndOutput.py
index 4fc467c..e052e6e 100644
--- a/cheetah/Tests/SyntaxAndOutput.py
+++ b/cheetah/Tests/SyntaxAndOutput.py
@@ -742,6 +742,12 @@ class EncodingDirective(OutputTest):
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 """