Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1df9c5b3
Commit
1df9c5b3
authored
May 07, 2012
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #14701: Add missing support for 'raise ... from' in parser module.
parent
40574dc5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
12 deletions
+21
-12
Lib/test/test_parser.py
Lib/test/test_parser.py
+8
-0
Misc/NEWS
Misc/NEWS
+2
-0
Modules/parsermodule.c
Modules/parsermodule.c
+11
-12
No files found.
Lib/test/test_parser.py
View file @
1df9c5b3
...
...
@@ -297,6 +297,14 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
self
.
check_suite
(
"[*a, *b] = y"
)
self
.
check_suite
(
"for [*x, b] in x: pass"
)
def
test_raise_statement
(
self
):
self
.
check_suite
(
"raise
\
n
"
)
self
.
check_suite
(
"raise e
\
n
"
)
self
.
check_suite
(
"try:
\
n
"
" suite
\
n
"
"except Exception as e:
\
n
"
" raise ValueError from e
\
n
"
)
#
# Second, we take *invalid* trees and make sure we get ParserError
...
...
Misc/NEWS
View file @
1df9c5b3
...
...
@@ -61,6 +61,8 @@ Core and Builtins
Library
-------
- Issue #14701: Fix missing support for 'raise ... from' in parser module.
- Issue #13183: Fix pdb skipping frames after hitting a breakpoint and running
step. Patch by Xavier de Gaye.
...
...
Modules/parsermodule.c
View file @
1df9c5b3
...
...
@@ -1608,31 +1608,30 @@ validate_return_stmt(node *tree)
}
/*
* raise_stmt:
*
* 'raise' [test ['from' test]]
*/
static
int
validate_raise_stmt
(
node
*
tree
)
{
int
nch
=
NCH
(
tree
);
int
res
=
(
validate_ntype
(
tree
,
raise_stmt
)
&&
((
nch
==
1
)
||
(
nch
==
2
)
||
(
nch
==
4
)
||
(
nch
==
6
)));
&&
((
nch
==
1
)
||
(
nch
==
2
)
||
(
nch
==
4
)));
if
(
!
res
&&
!
PyErr_Occurred
())
(
void
)
validate_numnodes
(
tree
,
2
,
"raise"
);
if
(
res
)
{
res
=
validate_name
(
CHILD
(
tree
,
0
),
"raise"
);
if
(
res
&&
(
nch
>=
2
))
res
=
validate_test
(
CHILD
(
tree
,
1
));
if
(
res
&&
nch
>
2
)
{
res
=
(
validate_
comma
(
CHILD
(
tree
,
2
)
)
if
(
res
&&
(
nch
==
4
)
)
{
res
=
(
validate_
name
(
CHILD
(
tree
,
2
),
"from"
)
&&
validate_test
(
CHILD
(
tree
,
3
)));
if
(
res
&&
(
nch
>
4
))
res
=
(
validate_comma
(
CHILD
(
tree
,
4
))
&&
validate_test
(
CHILD
(
tree
,
5
)));
}
}
else
(
void
)
validate_numnodes
(
tree
,
2
,
"raise"
);
if
(
res
&&
(
nch
==
4
))
res
=
(
validate_comma
(
CHILD
(
tree
,
2
))
&&
validate_test
(
CHILD
(
tree
,
3
)));
return
(
res
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment