Skip to content

Commit c20feed

Browse files
committed
Address review
1 parent 5758755 commit c20feed

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

Grammar/python.gram

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ invalid_case_block:
14841484
invalid_case_pattern:
14851485
| "case" a=expression guard? ':' block {
14861486
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
1487-
a, "cannot use case statement with %s", _PyPegen_get_expr_name(a)) }
1487+
a, "cannot use %s as case pattern", _PyPegen_get_expr_name(a)) }
14881488
invalid_as_pattern:
14891489
| or_pattern 'as' a="_" { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use '_' as a target") }
14901490
| or_pattern 'as' a=expression {

Lib/test/test_syntax.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,38 +374,38 @@
374374
... case {**rest, "key": value}:
375375
... ...
376376
Traceback (most recent call last):
377-
SyntaxError: cannot use case statement with dict literal
377+
SyntaxError: cannot use dict literal as case pattern
378378
379379
>>> match ...:
380380
... case {**_}:
381381
... ...
382382
Traceback (most recent call last):
383-
SyntaxError: cannot use case statement with dict literal
383+
SyntaxError: cannot use dict literal as case pattern
384384
385385
>>> match ...:
386386
... case ...: ...
387387
Traceback (most recent call last):
388-
SyntaxError: cannot use case statement with ellipsis
388+
SyntaxError: cannot use ellipsis as case pattern
389389
390390
>>> match ...:
391391
... case 1 // 2: ...
392392
Traceback (most recent call last):
393-
SyntaxError: cannot use case statement with expression
393+
SyntaxError: cannot use expression as case pattern
394394
395395
>>> match ...:
396396
... case {1, 2, 3}: ...
397397
Traceback (most recent call last):
398-
SyntaxError: cannot use case statement with set display
398+
SyntaxError: cannot use set display as case pattern
399399
400400
>>> match ...:
401401
... case a[0]: ...
402402
Traceback (most recent call last):
403-
SyntaxError: cannot use case statement with subscript
403+
SyntaxError: cannot use subscript as case pattern
404404
405405
>>> match ...:
406406
... case a[0].method(): ...
407407
Traceback (most recent call last):
408-
SyntaxError: cannot use case statement with function call
408+
SyntaxError: cannot use function call as case pattern
409409
410410
# But prefixes of soft keywords should
411411
# still raise specialized errors

Parser/parser.c

Lines 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)