summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-04-06 03:41:40 (GMT)
committerGuido van Rossum <guido@python.org>1997-04-06 03:41:40 (GMT)
commit5f5e817e001302c090ef3b04a66417fbc1c8a351 (patch)
treedd37b02390ea05c1ee4c23e2b36e6d3529b9fd1b /Python/compile.c
parent150853861a63ee0ea649e6d83f6ffff6524ae099 (diff)
downloadcpython-5f5e817e001302c090ef3b04a66417fbc1c8a351.zip
cpython-5f5e817e001302c090ef3b04a66417fbc1c8a351.tar.gz
cpython-5f5e817e001302c090ef3b04a66417fbc1c8a351.tar.bz2
Support for alternative string quotes (a"xx", b"xx", c"xx", ...).
In interactive mode, do generate code for single-string statements.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 0338d6f..7d9a3a8 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -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) {