[3.9] bpo-40176: Improve error messages for trailing comma on from import (GH-20294) (GH-20302)
(cherry picked from commit 72e0aa2)
Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index a82b444..6d9c4e4 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -641,6 +641,14 @@
Traceback (most recent call last):
SyntaxError: cannot assign to f-string expression
+>>> from t import x,
+Traceback (most recent call last):
+SyntaxError: trailing comma not allowed without surrounding parentheses
+
+>>> from t import x,y,
+Traceback (most recent call last):
+SyntaxError: trailing comma not allowed without surrounding parentheses
+
Corner-cases that used to fail to raise the correct error:
>>> def f(*, x=lambda __debug__:0): pass