summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2020-06-21 02:18:01 (GMT)
committerGitHub <noreply@github.com>2020-06-21 02:18:01 (GMT)
commit6c4e0bd974f2895d42b63d9d004587e74b286c88 (patch)
tree68e8df81c6375ba0e85e614f6afd92d867a901af /Lib/test/test_syntax.py
parent3ccb96c9782480e5ce646a4a130569fb92f2965d (diff)
downloadcpython-6c4e0bd974f2895d42b63d9d004587e74b286c88.zip
cpython-6c4e0bd974f2895d42b63d9d004587e74b286c88.tar.gz
cpython-6c4e0bd974f2895d42b63d9d004587e74b286c88.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r--Lib/test/test_syntax.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 9bb3d9e..812a7df 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -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