GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-94947: Disallow parsing walrus with feature_version < (3, 8) (GH-9… · python/cpython@7dc236d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Grammar
    • python.gram
  • Lib/test
    • test_ast.py
  • Misc/NEWS.d/next/Core and Builtins
    • 2022-07-18-04-48-34.gh-issue-94947.df9gUw.rst
  • Parser
    • parser.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Grammar/python.gram‎

Copy file name to clipboardExpand all lines: Grammar/python.gram
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,9 @@ star_named_expression[expr_ty]:
660660
| named_expression
661661

662662
assignment_expression[expr_ty]:
663-
| a=NAME ':=' ~ b=expression { _PyAST_NamedExpr(CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), b, EXTRA) }
663+
| a=NAME ':=' ~ b=expression {
664+
CHECK_VERSION(expr_ty, 8, "Assignment expressions are",
665+
_PyAST_NamedExpr(CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), b, EXTRA)) }
664666

665667
named_expression[expr_ty]:
666668
| assignment_expression
Collapse file

‎Lib/test/test_ast.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_ast.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,11 @@ def test_issue40614_feature_version(self):
743743
with self.assertRaises(SyntaxError):
744744
ast.parse('f"{x=}"', feature_version=(3, 7))
745745

746+
def test_assignment_expression_feature_version(self):
747+
ast.parse('(x := 0)', feature_version=(3, 8))
748+
with self.assertRaises(SyntaxError):
749+
ast.parse('(x := 0)', feature_version=(3, 7))
750+
746751
def test_constant_as_name(self):
747752
for constant in "True", "False", "None":
748753
expr = ast.Expression(ast.Name(constant, ast.Load()))
Collapse file

‎Misc/NEWS.d/next/Core and Builtins/2022-07-18-04-48-34.gh-issue-94947.df9gUw.rst‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:func:`ast.parse` will no longer parse assignment expressions when passed ``feature_version`` less than ``(3, 8)``. Patch by Shantanu Jain.
Collapse file

‎Parser/parser.c‎

Copy file name to clipboardExpand all lines: Parser/parser.c
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.