diff genshi/template/text.py @ 512:bdaf75981ec7

Fix for #125 (text template handling unicode source). Thanks to Christian Boos for the patch.
author cmlenz
date Wed, 06 Jun 2007 11:31:44 +0000
parents bb939ed3058c
children 7145e4eba2ec f0bb2c5ea0ff
line wrap: on
line diff
--- a/genshi/template/text.py
+++ b/genshi/template/text.py
@@ -64,10 +64,10 @@
         stream = [] # list of events of the "compiled" template
         dirmap = {} # temporary mapping of directives to elements
         depth = 0
-        if not encoding:
-            encoding = 'utf-8'
 
-        source = source.read().decode(encoding, 'replace')
+        source = source.read()
+        if isinstance(source, str):
+            source = source.decode(encoding or 'utf-8', 'replace')
         offset = 0
         lineno = 1
 
Copyright (C) 2012-2017 Edgewall Software