From: Stefan Behnel Date: Sun, 11 Oct 2009 08:38:53 +0000 (+0200) Subject: do not check identifiers for decodability X-Git-Tag: 0.13.beta0~2^2~121^2~73 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b0ed60f9f0f3993faeef04636885a666426ba048;p=cython.git do not check identifiers for decodability --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index ff0ad067..20d54391 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -903,7 +903,7 @@ class StringNode(PyConstNode): # A Python str object, i.e. a byte string in Python 2.x and a # unicode string in Python 3.x # - # value BytesLiteral + # value BytesLiteral or EncodedString # is_identifier boolean type = Builtin.str_type @@ -919,11 +919,12 @@ class StringNode(PyConstNode): self.check_for_coercion_error(dst_type, fail=True) # this will be a unicode string in Py3, so make sure we can decode it - encoding = self.value.encoding or 'UTF-8' - try: - self.value.decode(encoding) - except UnicodeDecodeError: - error(self.pos, "String decoding as '%s' failed. Consider using a byte string or unicode string explicitly, or adjust the source code encoding." % encoding) + if not self.is_identifier: + encoding = self.value.encoding or 'UTF-8' + try: + self.value.decode(encoding) + except UnicodeDecodeError: + error(self.pos, "String decoding as '%s' failed. Consider using a byte string or unicode string explicitly, or adjust the source code encoding." % encoding) return self