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 — bpo-45716: Improve the error message when using True/False/None as ke… · python/cpython@e2d6563

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Grammar
    • python.gram
  • Lib/test
    • test_syntax.py
  • Misc/NEWS.d/next/Core and Builtins
    • 2021-11-04-20-19-07.bpo-45716.5C0pA1.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
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,8 @@ invalid_arguments:
10621062
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, asdl_seq_GET(b, b->size-1)->target, "Generator expression must be parenthesized") }
10631063
| a=args ',' args { _PyPegen_arguments_parsing_error(p, a) }
10641064
invalid_kwarg:
1065+
| a[Token*]=('True'|'False'|'None') b='=' {
1066+
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot assign to %s", PyBytes_AS_STRING(a->bytes)) }
10651067
| a=NAME b='=' expression for_if_clauses {
10661068
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Maybe you meant '==' or ':=' instead of '='?")}
10671069
| !(NAME '=') a=expression b='=' {
Collapse file

‎Lib/test/test_syntax.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_syntax.py
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,15 @@
524524
>>> f((x)=2)
525525
Traceback (most recent call last):
526526
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
527-
>>> f(True=2)
527+
>>> f(True=1)
528528
Traceback (most recent call last):
529-
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
529+
SyntaxError: cannot assign to True
530+
>>> f(False=1)
531+
Traceback (most recent call last):
532+
SyntaxError: cannot assign to False
533+
>>> f(None=1)
534+
Traceback (most recent call last):
535+
SyntaxError: cannot assign to None
530536
>>> f(__debug__=1)
531537
Traceback (most recent call last):
532538
SyntaxError: cannot assign to __debug__
Collapse file

‎Misc/NEWS.d/next/Core and Builtins/2021-11-04-20-19-07.bpo-45716.5C0pA1.rst‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve the :exc:`SyntaxError` message when using ``True``, ``None`` or
2+
``False`` as keywords in a function call. Patch by Pablo Galindo.

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.