Mercurial > cpython-lru_cache-weakref
diff Python/compile.c @ 5264:38878f1cd4f1 legacy-trunk
Support for alternative string quotes (a"xx", b"xx", c"xx", ...).
In interactive mode, do generate code for single-string statements.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sun, 06 Apr 1997 03:41:40 +0000 |
| parents | b749d2dd7582 |
| children | 5af766a1b531 |
line wrap: on
line diff
--- a/Python/compile.c Thu Apr 03 23:49:28 1997 +0000 +++ b/Python/compile.c Sun Apr 06 03:41:40 1997 +0000 @@ -840,7 +840,10 @@ char *p; char *end; int c; - int quote = *s; + int first = *s; + int quote = first; + if (isalpha(quote) || quote == '_') + quote = *++s; if (quote != '\'' && quote != '\"') { err_badcall(); return NULL; @@ -859,7 +862,7 @@ return NULL; } } - if (strchr(s, '\\') == NULL) + if (first != quote || strchr(s, '\\') == NULL) return newsizedstringobject(s, len); v = newsizedstringobject((char *)NULL, len); p = buf = getstringvalue(v); @@ -1903,7 +1906,7 @@ { REQ(n, expr_stmt); /* testlist ('=' testlist)* */ /* Forget it if we have just a doc string here */ - if (NCH(n) == 1 && get_rawdocstring(n) != NULL) + if (!c->c_interactive && NCH(n) == 1 && get_rawdocstring(n) != NULL) return; com_node(c, CHILD(n, NCH(n)-1)); if (NCH(n) == 1) {
