Mercurial > genshi > mirror
view fixes/fix_unicode_in_strings.py @ 918:f05002a6d078 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 | c74a141a48ff |
children |
line wrap: on
line source
"""Fixer that changes expressions inside strings literals from u"..." to "...". """ import re from lib2to3 import fixer_base _literal_re = re.compile(r"(.+?)\b[uU]([rR]?[\'\"])") class FixUnicodeInStrings(fixer_base.BaseFix): PATTERN = "STRING" def transform(self, node, results): new = node.clone() new.value = _literal_re.sub(r"\1\2", new.value) return new