mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
Support for alternative string quotes (a"xx", b"xx", c"xx", ...).
In interactive mode, do generate code for single-string statements.
This commit is contained in:
parent
150853861a
commit
5f5e817e00
1 changed files with 6 additions and 3 deletions
|
|
@ -840,7 +840,10 @@ parsestr(s)
|
||||||
char *p;
|
char *p;
|
||||||
char *end;
|
char *end;
|
||||||
int c;
|
int c;
|
||||||
int quote = *s;
|
int first = *s;
|
||||||
|
int quote = first;
|
||||||
|
if (isalpha(quote) || quote == '_')
|
||||||
|
quote = *++s;
|
||||||
if (quote != '\'' && quote != '\"') {
|
if (quote != '\'' && quote != '\"') {
|
||||||
err_badcall();
|
err_badcall();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -859,7 +862,7 @@ parsestr(s)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strchr(s, '\\') == NULL)
|
if (first != quote || strchr(s, '\\') == NULL)
|
||||||
return newsizedstringobject(s, len);
|
return newsizedstringobject(s, len);
|
||||||
v = newsizedstringobject((char *)NULL, len);
|
v = newsizedstringobject((char *)NULL, len);
|
||||||
p = buf = getstringvalue(v);
|
p = buf = getstringvalue(v);
|
||||||
|
|
@ -1903,7 +1906,7 @@ com_expr_stmt(c, n)
|
||||||
{
|
{
|
||||||
REQ(n, expr_stmt); /* testlist ('=' testlist)* */
|
REQ(n, expr_stmt); /* testlist ('=' testlist)* */
|
||||||
/* Forget it if we have just a doc string here */
|
/* 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;
|
return;
|
||||||
com_node(c, CHILD(n, NCH(n)-1));
|
com_node(c, CHILD(n, NCH(n)-1));
|
||||||
if (NCH(n) == 1) {
|
if (NCH(n) == 1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue