diff genshi/template/loader.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 85e4678337cf
children
line wrap: on
line diff
--- a/genshi/template/loader.py
+++ b/genshi/template/loader.py
@@ -46,7 +46,7 @@
     
     >>> import tempfile
     >>> fd, path = tempfile.mkstemp(suffix='.html', prefix='template')
-    >>> os.write(fd, '<p>$var</p>')
+    >>> os.write(fd, u'<p>$var</p>'.encode('utf-8'))
     11
     >>> os.close(fd)
     
@@ -283,7 +283,7 @@
         """
         def _load_from_directory(filename):
             filepath = os.path.join(path, filename)
-            fileobj = open(filepath, 'U')
+            fileobj = open(filepath, 'rbU')
             mtime = os.path.getmtime(filepath)
             def _uptodate():
                 return mtime == os.path.getmtime(filepath)
Copyright (C) 2012-2017 Edgewall Software