mirror of
https://github.com/python/cpython.git
synced 2025-10-22 14:42:22 +00:00
Issue #14701: Merge fix from 3.2.
This commit is contained in:
commit
9fad160411
3 changed files with 21 additions and 12 deletions
|
@ -301,6 +301,14 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
|
||||||
self.check_suite("[*a, *b] = y")
|
self.check_suite("[*a, *b] = y")
|
||||||
self.check_suite("for [*x, b] in x: pass")
|
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
|
# Second, we take *invalid* trees and make sure we get ParserError
|
||||||
|
|
|
@ -20,6 +20,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #14701: Fix missing support for 'raise ... from' in parser module.
|
||||||
|
|
||||||
- Add support for timeouts to the acquire() methods of
|
- Add support for timeouts to the acquire() methods of
|
||||||
multiprocessing's lock/semaphore/condition proxies.
|
multiprocessing's lock/semaphore/condition proxies.
|
||||||
|
|
||||||
|
|
|
@ -1611,31 +1611,30 @@ validate_return_stmt(node *tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* raise_stmt:
|
||||||
|
*
|
||||||
|
* 'raise' [test ['from' test]]
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
validate_raise_stmt(node *tree)
|
validate_raise_stmt(node *tree)
|
||||||
{
|
{
|
||||||
int nch = NCH(tree);
|
int nch = NCH(tree);
|
||||||
int res = (validate_ntype(tree, raise_stmt)
|
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) {
|
if (res) {
|
||||||
res = validate_name(CHILD(tree, 0), "raise");
|
res = validate_name(CHILD(tree, 0), "raise");
|
||||||
if (res && (nch >= 2))
|
if (res && (nch >= 2))
|
||||||
res = validate_test(CHILD(tree, 1));
|
res = validate_test(CHILD(tree, 1));
|
||||||
if (res && nch > 2) {
|
if (res && (nch == 4)) {
|
||||||
res = (validate_comma(CHILD(tree, 2))
|
res = (validate_name(CHILD(tree, 2), "from")
|
||||||
&& validate_test(CHILD(tree, 3)));
|
&& 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);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue