mirror of
https://github.com/python/cpython.git
synced 2025-07-07 11:25:30 +00:00
This commit is contained in:
parent
fc82cb91ba
commit
7e33558455
4 changed files with 2509 additions and 2505 deletions
|
@ -184,8 +184,9 @@ return_stmt[stmt_ty]:
|
|||
| 'return' a=[star_expressions] { _PyAST_Return(a, EXTRA) }
|
||||
|
||||
raise_stmt[stmt_ty]:
|
||||
| 'raise' a=expression 'from' b=expression { _PyAST_Raise(a, b, EXTRA) }
|
||||
| invalid_raise_stmt
|
||||
| 'raise' a=expression b=['from' z=expression { z }] { _PyAST_Raise(a, b, EXTRA) }
|
||||
| 'raise' a=expression { _PyAST_Raise(a, NULL, EXTRA) }
|
||||
| 'raise' { _PyAST_Raise(NULL, NULL, EXTRA) }
|
||||
|
||||
pass_stmt[stmt_ty]:
|
||||
|
|
|
@ -2872,6 +2872,13 @@ class SyntaxErrorTestCase(unittest.TestCase):
|
|||
"""
|
||||
self._check_error(source, "parameter and nonlocal", lineno=3)
|
||||
|
||||
def test_raise_from_error_message(self):
|
||||
source = """if 1:
|
||||
raise AssertionError() from None
|
||||
print(1,,2)
|
||||
"""
|
||||
self._check_error(source, "invalid syntax", lineno=3)
|
||||
|
||||
def test_yield_outside_function(self):
|
||||
self._check_error("if 0: yield", "outside function")
|
||||
self._check_error("if 0: yield\nelse: x=1", "outside function")
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix regression in :exc:`SyntaxError` messages after :gh:`134036`.
|
5003
Parser/parser.c
generated
5003
Parser/parser.c
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue