bpo-44273: Improve syntax error message for assigning to "..." (GH-26477)
June 1, 2021
11:07 a.m.
https://github.com/python/cpython/commit/39dd141a4ba68bbb38fd00a65cdcff711acdafb5
commit: 39dd141a4ba68bbb38fd00a65cdcff711acdafb5
branch: main
author: Serhiy Storchaka <storchaka@gmail.com>
committer: pablogsal <Pablogsal@gmail.com>
date: 2021-06-01T12:07:05+01:00
summary:
bpo-44273: Improve syntax error message for assigning to "..." (GH-26477)
Use "ellipsis" instead of "Ellipsis" in syntax error messages to eliminate confusion with built-in variable Ellipsis.
files:
M Lib/test/test_syntax.py
M Parser/pegen.c
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index cc189ef0f54b5..c000028e5f1aa 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -93,7 +93,7 @@
>>> ... = 1
Traceback (most recent call last):
-SyntaxError: cannot assign to Ellipsis here. Maybe you meant '==' instead of '='?
+SyntaxError: cannot assign to ellipsis here. Maybe you meant '==' instead of '='?
>>> `1` = 1
Traceback (most recent call last):
diff --git a/Parser/pegen.c b/Parser/pegen.c
index 548a64788dec4..aac7e368a799f 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -217,7 +217,7 @@ _PyPegen_get_expr_name(expr_ty e)
return "True";
}
if (value == Py_Ellipsis) {
- return "Ellipsis";
+ return "ellipsis";
}
return "literal";
}
1786
Age (days ago)
1786
Last active (days ago)
0 comments
1 participants
participants (1)
-
pablogsal