]> granicus.if.org Git - python/commitdiff
Support for alternative string quotes (a"xx", b"xx", c"xx", ...).
authorGuido van Rossum <guido@python.org>
Sun, 6 Apr 1997 03:41:40 +0000 (03:41 +0000)
committerGuido van Rossum <guido@python.org>
Sun, 6 Apr 1997 03:41:40 +0000 (03:41 +0000)
In interactive mode, do generate code for single-string statements.

Python/compile.c

index 0338d6ff45f37569d913fc4c26b392695c9b5e41..7d9a3a8921814efba80bb5628ea11a4f499f4d39 100644 (file)
@@ -840,7 +840,10 @@ parsestr(s)
        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 @@ parsestr(s)
                        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 @@ com_expr_stmt(c, n)
 {
        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) {