1.1 --- a/common.py Fri Jan 27 23:54:18 2017 +0100
1.2 +++ b/common.py Sat Jan 28 13:27:31 2017 +0100
1.3 @@ -246,11 +246,10 @@
1.4 # Attempt to convert plain strings to text.
1.5
1.6 elif isinstance(value, str) and self.encoding:
1.7 - if not literal.startswith("b"):
1.8 - try:
1.9 - return get_string_details(literal, self.encoding)
1.10 - except UnicodeDecodeError:
1.11 - pass
1.12 + try:
1.13 + return get_string_details(literal, self.encoding)
1.14 + except UnicodeDecodeError:
1.15 + pass
1.16
1.17 return value, value.__class__.__name__, None
1.18
1.19 @@ -989,7 +988,6 @@
1.20 """
1.21
1.22 l = []
1.23 - typename = "unicode"
1.24
1.25 # Identify the quote character and use it to identify the prefix.
1.26
1.27 @@ -1000,6 +998,11 @@
1.28 if prefix not in ("", "b", "br", "r", "u", "ur"):
1.29 raise ValueError, "String literal does not have a supported prefix: %s" % s
1.30
1.31 + if "b" in prefix:
1.32 + typename = "str"
1.33 + else:
1.34 + typename = "unicode"
1.35 +
1.36 # Identify triple quotes or single quotes.
1.37
1.38 if len(s) >= 6 and s[-2] == quote_type and s[-3] == quote_type:
1.39 @@ -1049,8 +1052,9 @@
1.40 # Add Unicode values. Where a string is u-prefixed, even \o and \x
1.41 # produce Unicode values.
1.42
1.43 - if term in ("u", "U") or prefix == "u" and (
1.44 - term == "x" or term in octal_digits):
1.45 + if typename == "unicode" and (
1.46 + term in ("u", "U") or
1.47 + "u" in prefix and (term == "x" or term in octal_digits)):
1.48
1.49 needed, base = searches.get(term, (4, 8))
1.50 value = convert_quoted_value(s, index, needed, end, base, unichr)