Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 5 Lib/test/test_tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,11 @@ def test_async(self):
NAME 'async' (1, 0) (1, 5)
OP '=' (1, 6) (1, 7)
NUMBER '1' (1, 8) (1, 9)
""")

self.check_tokenize("async\\", """\
ERRORTOKEN '\\\\' (1, 5) (1, 6)
NAME 'async' (1, 0) (1, 5)
""")

self.check_tokenize("a = (async = 1)", """\
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a segmentation fault caused by a combination of the async soft keyword
and continuation lines.
10 changes: 10 additions & 0 deletions 10 Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,9 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
/* The current token is 'async'.
Look ahead one token.*/

int async_def_prev = tok->async_def;
tok->async_def = 2;

struct tok_state ahead_tok;
char *ahead_tok_start = NULL, *ahead_tok_end = NULL;
int ahead_tok_kind;
Expand All @@ -1581,6 +1584,9 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
tok->async_def = 1;
return ASYNC;
}
else{
tok->async_def = async_def_prev;
}
}
}

Expand Down Expand Up @@ -1844,6 +1850,10 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
/* Line continuation */
if (c == '\\') {
c = tok_nextc(tok);
if (tok->async_def == 2) {
tok->done = E_SYNTAX;
return ERRORTOKEN;
}
if (c != '\n') {
tok->done = E_LINECONT;
tok->cur = tok->inp;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.