diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-06-09 21:20:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-09 21:20:01 (GMT) |
commit | 457ce60fc70f1c9290023f46fb82b6a490dff32e (patch) | |
tree | ce11ef3395d5dee461c809150b57c7ea8f212596 /Parser | |
parent | 878d7e4ee464913438fd59582bbb795e7e0fa387 (diff) | |
download | cpython-457ce60fc70f1c9290023f46fb82b6a490dff32e.zip cpython-457ce60fc70f1c9290023f46fb82b6a490dff32e.tar.gz cpython-457ce60fc70f1c9290023f46fb82b6a490dff32e.tar.bz2 |
bpo-44368: Ensure we don't raise incorrect custom syntax errors with soft keywords (GH-26630)
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/pegen.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c index e651819..82f840c 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -936,10 +936,9 @@ _PyPegen_get_last_nonnwhitespace_token(Parser *p) return token; } -expr_ty -_PyPegen_name_token(Parser *p) +static expr_ty +_PyPegen_name_from_token(Parser *p, Token* t) { - Token *t = _PyPegen_expect_token(p, NAME); if (t == NULL) { return NULL; } @@ -957,6 +956,14 @@ _PyPegen_name_token(Parser *p) t->end_col_offset, p->arena); } + +expr_ty +_PyPegen_name_token(Parser *p) +{ + Token *t = _PyPegen_expect_token(p, NAME); + return _PyPegen_name_from_token(p, t); +} + void * _PyPegen_string_token(Parser *p) { @@ -974,7 +981,7 @@ expr_ty _PyPegen_soft_keyword_token(Parser *p) { PyBytes_AsStringAndSize(t->bytes, &the_token, &size); for (char **keyword = p->soft_keywords; *keyword != NULL; keyword++) { if (strncmp(*keyword, the_token, size) == 0) { - return _PyPegen_name_token(p); + return _PyPegen_name_from_token(p, t); } } return NULL; |