bpo-41060: Avoid SEGFAULT when calling GET_INVALID_TARGET in the grammar (GH-21020)

`GET_INVALID_TARGET` might unexpectedly return `NULL`, which if not
caught will cause a SEGFAULT. Therefore, this commit introduces a new
inline function `RAISE_SYNTAX_ERROR_INVALID_TARGET` that always
checks for `GET_INVALID_TARGET` returning NULL and can be used in
the grammar, replacing the long C ternary operation used till now.
This commit is contained in:
Lysandros Nikolaou 2020-06-21 05:18:01 +03:00 committed by GitHub
parent 3ccb96c978
commit 6c4e0bd974
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 26 deletions

View file

@ -199,6 +199,10 @@ SyntaxError: cannot assign to operator
Traceback (most recent call last):
SyntaxError: invalid syntax
>>> for a, b
Traceback (most recent call last):
SyntaxError: invalid syntax
>>> with a as b(): pass
Traceback (most recent call last):
SyntaxError: cannot assign to function call
@ -223,6 +227,10 @@ SyntaxError: cannot assign to function call
Traceback (most recent call last):
SyntaxError: cannot assign to function call
>>> with a as b
Traceback (most recent call last):
SyntaxError: invalid syntax
>>> p = p =
Traceback (most recent call last):
SyntaxError: invalid syntax