Mercurial > genshi > genshi-test
view fixes/fix_unicode_in_strings.py @ 915:9fafb35032a1 experimental-py3k
add support for python 3 to core genshi components (genshi.core, genshi.input and genshi.output):
* default input and output encodings changed from UTF-8 to None (i.e. unicode strings)
* Namespace and QName objects do not call stringrepr in __repr__ in Python 3 since repr() returns a unicode string there.
* track changes to expat parser in Python 3 (mostly it accepts bytes instead of strings)
author | hodgestar |
---|---|
date | Sun, 24 Oct 2010 22:08:11 +0000 |
parents | 46db99909472 |
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