summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-05-28 18:47:29 (GMT)
committerGuido van Rossum <guido@python.org>2002-05-28 18:47:29 (GMT)
commit05459c5e5ece64ba8da62455970d1c1479011ff7 (patch)
treea282c5c6c21518aed2d47e1c440fa00217ce5c13 /Python
parentc88da1faa5bfa9b72b38822cb9745ad7be7606a3 (diff)
downloadcpython-05459c5e5ece64ba8da62455970d1c1479011ff7.zip
cpython-05459c5e5ece64ba8da62455970d1c1479011ff7.tar.gz
cpython-05459c5e5ece64ba8da62455970d1c1479011ff7.tar.bz2
Accept u"..." literals even when Unicode is disabled. But these
literals must not contain \u, \U or \N escapes. (XXX Should they also not contain non-ASCII characters?)
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/Python/compile.c b/Python/compile.c
index d41867f..cdb72ac 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1130,19 +1130,12 @@ parsestr(struct compiling *com, char *s)
int first = *s;
int quote = first;
int rawmode = 0;
-#ifdef Py_USING_UNICODE
int unicode = 0;
-#endif
+
if (isalpha(quote) || quote == '_') {
if (quote == 'u' || quote == 'U') {
-#ifdef Py_USING_UNICODE
quote = *++s;
unicode = 1;
-#else
- com_error(com, PyExc_SyntaxError,
- "Unicode literals not supported in this Python");
- return NULL;
-#endif
}
if (quote == 'r' || quote == 'R') {
quote = *++s;
@@ -1250,6 +1243,18 @@ parsestr(struct compiling *com, char *s)
com_error(com, PyExc_ValueError,
"invalid \\x escape");
return NULL;
+#ifndef Py_USING_UNICODE
+ case 'u':
+ case 'U':
+ case 'N':
+ if (unicode) {
+ Py_DECREF(v);
+ com_error(com, PyExc_ValueError,
+ "Unicode escapes not legal "
+ "when Unicode disabled");
+ return NULL;
+ }
+#endif
default:
*p++ = '\\';
*p++ = s[-1];