view fixes/fix_unicode_in_strings.py @ 939:f15334b65cf8 trunk

Don't cache (TEXT, Markup) events in serializers. This is not needed and since Markup instances compare equal to the same non-Markup string this can lead to incorrect cached output being retrieved. Fixes #429. This is patch t429-fix.2.patch from that ticket. It includes an additional unrelated test to check that the WhitespaceFilter actually removes ignorable whitespace.
author hodgestar
date Sun, 12 Jun 2011 00:41:35 +0000
parents d010a80ebb4f
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
Copyright (C) 2012-2017 Edgewall Software