Mercurial > genshi > genshi-test
comparison genshi/template/text.py @ 935:705727288d7e
Merge r1143 from 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 | Fri, 18 Mar 2011 09:17:52 +0000 |
parents | 6638c9db9e8c |
children |
comparison
equal
deleted
inserted
replaced
934:7c9ec79caedc | 935:705727288d7e |
---|---|
160 stream = [] # list of events of the "compiled" template | 160 stream = [] # list of events of the "compiled" template |
161 dirmap = {} # temporary mapping of directives to elements | 161 dirmap = {} # temporary mapping of directives to elements |
162 depth = 0 | 162 depth = 0 |
163 | 163 |
164 source = source.read() | 164 source = source.read() |
165 if isinstance(source, str): | 165 if not isinstance(source, unicode): |
166 source = source.decode(encoding or 'utf-8', 'replace') | 166 source = source.decode(encoding or 'utf-8', 'replace') |
167 offset = 0 | 167 offset = 0 |
168 lineno = 1 | 168 lineno = 1 |
169 | 169 |
170 _escape_sub = self._escape_re.sub | 170 _escape_sub = self._escape_re.sub |
277 stream = [] # list of events of the "compiled" template | 277 stream = [] # list of events of the "compiled" template |
278 dirmap = {} # temporary mapping of directives to elements | 278 dirmap = {} # temporary mapping of directives to elements |
279 depth = 0 | 279 depth = 0 |
280 | 280 |
281 source = source.read() | 281 source = source.read() |
282 if isinstance(source, str): | 282 if not isinstance(source, unicode): |
283 source = source.decode(encoding or 'utf-8', 'replace') | 283 source = source.decode(encoding or 'utf-8', 'replace') |
284 offset = 0 | 284 offset = 0 |
285 lineno = 1 | 285 lineno = 1 |
286 | 286 |
287 for idx, mo in enumerate(self._DIRECTIVE_RE.finditer(source)): | 287 for idx, mo in enumerate(self._DIRECTIVE_RE.finditer(source)): |