@@ -903,7 +903,7 @@ class StringNode(PyConstNode):
...
@@ -903,7 +903,7 @@ class StringNode(PyConstNode):
# A Python str object, i.e. a byte string in Python 2.x and a
# A Python str object, i.e. a byte string in Python 2.x and a
# unicode string in Python 3.x
# unicode string in Python 3.x
#
#
# value BytesLiteral
# value BytesLiteral or EncodedString
# is_identifier boolean
# is_identifier boolean
type=Builtin.str_type
type=Builtin.str_type
...
@@ -919,11 +919,12 @@ class StringNode(PyConstNode):
...
@@ -919,11 +919,12 @@ class StringNode(PyConstNode):
self.check_for_coercion_error(dst_type,fail=True)
self.check_for_coercion_error(dst_type,fail=True)
# this will be a unicode string in Py3, so make sure we can decode it
# this will be a unicode string in Py3, so make sure we can decode it
encoding=self.value.encodingor'UTF-8'
ifnotself.is_identifier:
try:
encoding=self.value.encodingor'UTF-8'
self.value.decode(encoding)
try:
exceptUnicodeDecodeError:
self.value.decode(encoding)
error(self.pos,"String decoding as '%s' failed. Consider using a byte string or unicode string explicitly, or adjust the source code encoding."%encoding)
exceptUnicodeDecodeError:
error(self.pos,"String decoding as '%s' failed. Consider using a byte string or unicode string explicitly, or adjust the source code encoding."%encoding)