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

Skip to content

Commit 4bf108d

Browse files
committed
Patch #802188: better parser error message for non-EOL following line cont.
1 parent a4dac40 commit 4bf108d

4 files changed

Lines changed: 8 additions & 1 deletion

File tree

Include/errcode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ extern "C" {
2828
#define E_DECODE 22 /* Error in decoding into Unicode */
2929
#define E_EOFS 23 /* EOF in triple-quoted string */
3030
#define E_EOLS 24 /* EOL in single-quoted string */
31+
#define E_LINECONT 25 /* Unexpected characters after a line continuation */
3132

3233
#ifdef __cplusplus
3334
}

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 2.5 alpha 1?
1010
Core and builtins
1111
-----------------
1212

13+
- Patch #802188: Report characters after line continuation character
14+
('\') with a specific error message.
15+
1316
- Bug #723201: Raise a TypeError for passing bad objects to 'L' format.
1417

1518
- Bug #1124295: the __name__ attribute of file objects was

Parser/tokenizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
14131413
if (c == '\\') {
14141414
c = tok_nextc(tok);
14151415
if (c != '\n') {
1416-
tok->done = E_TOKEN;
1416+
tok->done = E_LINECONT;
14171417
tok->cur = tok->inp;
14181418
return ERRORTOKEN;
14191419
}

Python/pythonrun.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,9 @@ err_input(perrdetail *err)
14841484
msg = "unknown decode error";
14851485
break;
14861486
}
1487+
case E_LINECONT:
1488+
msg = "unexpected character after line continuation character";
1489+
break;
14871490
default:
14881491
fprintf(stderr, "error=%d\n", err->error);
14891492
msg = "unknown parsing error";

0 commit comments

Comments
 (0)