From b0ed60f9f0f3993faeef04636885a666426ba048 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 11 Oct 2009 10:38:53 +0200 Subject: [PATCH] do not check identifiers for decodability --- Cython/Compiler/ExprNodes.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 -- 2.26.2