diff genshi/template/text.py @ 918:006b0fa6991c experimental-py3k

add support for python 3 to remaining genshi.template components: * minor changes to track encoding=None API change in core genshi modules. * genshi/template/directives: * slightly odd syntax changes to make the 2to3 .next() fixer pick up *stream.next() * minor test fix for change in behaviour of division (/) in Python 3. * genshi/template/loader: * add 'b' to file modes to ensure it's loaded as bytes in Python 3. * use not isinstance(s, unicode) instead of isinstance(s, str) since the former is correctly converted by 2to3.
author hodgestar
date Sun, 24 Oct 2010 22:48:15 +0000
parents 6638c9db9e8c
children
line wrap: on
line diff
--- a/genshi/template/text.py
+++ b/genshi/template/text.py
@@ -162,7 +162,7 @@
         depth = 0
 
         source = source.read()
-        if isinstance(source, str):
+        if not isinstance(source, unicode):
             source = source.decode(encoding or 'utf-8', 'replace')
         offset = 0
         lineno = 1
@@ -279,7 +279,7 @@
         depth = 0
 
         source = source.read()
-        if isinstance(source, str):
+        if not isinstance(source, unicode):
             source = source.decode(encoding or 'utf-8', 'replace')
         offset = 0
         lineno = 1
Copyright (C) 2012-2017 Edgewall Software