summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2013-01-06 20:26:39 +0100
committerStefan Behnel <stefan_ml@behnel.de>2013-01-06 20:26:39 +0100
commita67eabb8cbe7517aba745530083371f12935a2cb (patch)
treed574a21b3616636fc41e6e1b57f9e9586e727e6f
parent2a9d8d459f09b9dcc8d3c0322a2227a3fed70b45 (diff)
downloadcython-a67eabb8cbe7517aba745530083371f12935a2cb.tar.gz
add error test case for unknown \N{...} Unicode escape name
-rw-r--r--Cython/Compiler/Parsing.py3
-rw-r--r--tests/errors/invalid_uescapeN.pyx7
2 files changed, 9 insertions, 1 deletions
diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py
index 0850ed4fc..a27cc6d30 100644
--- a/Cython/Compiler/Parsing.py
+++ b/Cython/Compiler/Parsing.py
@@ -815,7 +815,8 @@ def p_string_literal(s, kind_override=None):
try:
chrval = ord(unicodedata.lookup(systr[3:-1]))
except KeyError:
- s.error("Unknown Unicode character name %r" % systr[3:-1])
+ s.error("Unknown Unicode character name %s" %
+ repr(systr[3:-1]).lstrip('u'))
elif len(systr) in (6,10):
chrval = int(systr[2:], 16)
if chrval > 1114111: # sys.maxunicode:
diff --git a/tests/errors/invalid_uescapeN.pyx b/tests/errors/invalid_uescapeN.pyx
new file mode 100644
index 000000000..3d5a3597b
--- /dev/null
+++ b/tests/errors/invalid_uescapeN.pyx
@@ -0,0 +1,7 @@
+# mode: error
+
+u'\N{GIBBET NICH}'
+
+_ERRORS = '''
+3:2: Unknown Unicode character name 'GIBBET NICH'
+'''