Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5f5e817

Browse files
committed
Support for alternative string quotes (a"xx", b"xx", c"xx", ...).
In interactive mode, do generate code for single-string statements.
1 parent 1508538 commit 5f5e817

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Python/compile.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,10 @@ parsestr(s)
840840
char *p;
841841
char *end;
842842
int c;
843-
int quote = *s;
843+
int first = *s;
844+
int quote = first;
845+
if (isalpha(quote) || quote == '_')
846+
quote = *++s;
844847
if (quote != '\'' && quote != '\"') {
845848
err_badcall();
846849
return NULL;
@@ -859,7 +862,7 @@ parsestr(s)
859862
return NULL;
860863
}
861864
}
862-
if (strchr(s, '\\') == NULL)
865+
if (first != quote || strchr(s, '\\') == NULL)
863866
return newsizedstringobject(s, len);
864867
v = newsizedstringobject((char *)NULL, len);
865868
p = buf = getstringvalue(v);
@@ -1903,7 +1906,7 @@ com_expr_stmt(c, n)
19031906
{
19041907
REQ(n, expr_stmt); /* testlist ('=' testlist)* */
19051908
/* Forget it if we have just a doc string here */
1906-
if (NCH(n) == 1 && get_rawdocstring(n) != NULL)
1909+
if (!c->c_interactive && NCH(n) == 1 && get_rawdocstring(n) != NULL)
19071910
return;
19081911
com_node(c, CHILD(n, NCH(n)-1));
19091912
if (NCH(n) == 1) {

0 commit comments

Comments
 (0)