Mercurial > cpython-lru_cache-weakref
diff Python/compile.c @ 23555:c4fa37f89783 legacy-trunk
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?)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 28 May 2002 18:47:29 +0000 |
| parents | 9e67a0d5705f |
| children | b0658feef939 |
line wrap: on
line diff
--- a/Python/compile.c Tue May 28 10:58:19 2002 +0000 +++ b/Python/compile.c Tue May 28 18:47:29 2002 +0000 @@ -1130,19 +1130,12 @@ 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 @@ 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];
