summaryrefslogtreecommitdiff
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2021-06-04 00:11:43 +0100
committerGitHub <noreply@github.com>2021-06-04 00:11:43 +0100
commite53f72a1b42e17a331ed14bec674b1ee01d0720c (patch)
treefd4f350d1f95abc3f8107ebf9167a554d93ba23d /Lib/test/test_syntax.py
parent3283bf4519139cf62ba04a76930f84ca1e7da910 (diff)
downloadcpython-git-e53f72a1b42e17a331ed14bec674b1ee01d0720c.tar.gz
[3.10] bpo-44305: Improve syntax error for try blocks without except or finally (GH-26523) (GH-26524)
(cherry picked from commit b250f89bb7e05e72a4641d44b988866b919575db) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
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 c000028e5f..5d3ce4cd9f 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -882,6 +882,14 @@ leading to spurious errors.
Traceback (most recent call last):
SyntaxError: cannot assign to attribute here. Maybe you meant '==' instead of '='?
+Custom error messages for try blocks that are not followed by except/finally
+
+ >>> try:
+ ... x = 34
+ ...
+ Traceback (most recent call last):
+ SyntaxError: expected 'except' or 'finally' block
+
Ensure that early = are not matched by the parser as invalid comparisons
>>> f(2, 4, x=34); 1 $ 2
Traceback (most recent call last):