provide less mysterious error messages when seeing end-of-line in
single-quoted strings or end-of-file in triple-quoted strings. closes patch 586561.
This commit is contained in:
parent
90e9a79afd
commit
118ec70ea2
@ -26,6 +26,8 @@ extern "C" {
|
|||||||
#define E_TOODEEP 20 /* Too many indentation levels */
|
#define E_TOODEEP 20 /* Too many indentation levels */
|
||||||
#define E_DEDENT 21 /* No matching outer block for dedent */
|
#define E_DEDENT 21 /* No matching outer block for dedent */
|
||||||
#define E_DECODE 22 /* Error in decoding into Unicode */
|
#define E_DECODE 22 /* Error in decoding into Unicode */
|
||||||
|
#define E_EOFS 23 /* EOF in triple-quoted string */
|
||||||
|
#define E_EOLS 24 /* EOL in single-quoted string */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -1276,14 +1276,17 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
|
|||||||
c = tok_nextc(tok);
|
c = tok_nextc(tok);
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
if (!triple) {
|
if (!triple) {
|
||||||
tok->done = E_TOKEN;
|
tok->done = E_EOLS;
|
||||||
tok_backup(tok, c);
|
tok_backup(tok, c);
|
||||||
return ERRORTOKEN;
|
return ERRORTOKEN;
|
||||||
}
|
}
|
||||||
tripcount = 0;
|
tripcount = 0;
|
||||||
}
|
}
|
||||||
else if (c == EOF) {
|
else if (c == EOF) {
|
||||||
tok->done = E_TOKEN;
|
if (triple)
|
||||||
|
tok->done = E_EOFS;
|
||||||
|
else
|
||||||
|
tok->done = E_EOLS;
|
||||||
tok->cur = tok->inp;
|
tok->cur = tok->inp;
|
||||||
return ERRORTOKEN;
|
return ERRORTOKEN;
|
||||||
}
|
}
|
||||||
@ -1305,7 +1308,7 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
|
|||||||
tripcount = 0;
|
tripcount = 0;
|
||||||
c = tok_nextc(tok);
|
c = tok_nextc(tok);
|
||||||
if (c == EOF) {
|
if (c == EOF) {
|
||||||
tok->done = E_TOKEN;
|
tok->done = E_EOLS;
|
||||||
tok->cur = tok->inp;
|
tok->cur = tok->inp;
|
||||||
return ERRORTOKEN;
|
return ERRORTOKEN;
|
||||||
}
|
}
|
||||||
|
@ -1247,6 +1247,12 @@ err_input(perrdetail *err)
|
|||||||
case E_TOKEN:
|
case E_TOKEN:
|
||||||
msg = "invalid token";
|
msg = "invalid token";
|
||||||
break;
|
break;
|
||||||
|
case E_EOFS:
|
||||||
|
msg = "EOF while scanning triple-quoted string";
|
||||||
|
break;
|
||||||
|
case E_EOLS:
|
||||||
|
msg = "EOL while scanning single-quoted string";
|
||||||
|
break;
|
||||||
case E_INTR:
|
case E_INTR:
|
||||||
PyErr_SetNone(PyExc_KeyboardInterrupt);
|
PyErr_SetNone(PyExc_KeyboardInterrupt);
|
||||||
Py_XDECREF(v);
|
Py_XDECREF(v);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user