Skip to content
This repository was archived by the owner on Jul 5, 2023. It is now read-only.

Commit 19d2c62

Browse files
authored
Fix some broken asserts relating to handling of async keyword (#92)
typed_ast reintroduces ASYNC as a token after cpython 3.7 removed it. Fix asserts that still wanted it to be a NAME.
1 parent c6d7fcb commit 19d2c62

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

ast3/Python/ast.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,8 +1820,7 @@ ast_for_async_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_se
18201820
{
18211821
/* async_funcdef: 'async' funcdef */
18221822
REQ(n, async_funcdef);
1823-
REQ(CHILD(n, 0), NAME);
1824-
assert(strcmp(STR(CHILD(n, 0)), "async") == 0);
1823+
REQ(CHILD(n, 0), ASYNC);
18251824
REQ(CHILD(n, 1), funcdef);
18261825

18271826
return ast_for_funcdef_impl(c, n, decorator_seq,
@@ -1842,8 +1841,7 @@ ast_for_async_stmt(struct compiling *c, const node *n)
18421841
{
18431842
/* async_stmt: 'async' (funcdef | with_stmt | for_stmt) */
18441843
REQ(n, async_stmt);
1845-
REQ(CHILD(n, 0), NAME);
1846-
assert(strcmp(STR(CHILD(n, 0)), "async") == 0);
1844+
REQ(CHILD(n, 0), ASYNC);
18471845

18481846
switch (TYPE(CHILD(n, 1))) {
18491847
case funcdef:
@@ -1961,8 +1959,7 @@ count_comp_fors(struct compiling *c, const node *n)
19611959
n_fors++;
19621960
REQ(n, comp_for);
19631961
if (NCH(n) == 2) {
1964-
REQ(CHILD(n, 0), NAME);
1965-
assert(strcmp(STR(CHILD(n, 0)), "async") == 0);
1962+
REQ(CHILD(n, 0), ASYNC);
19661963
n = CHILD(n, 1);
19671964
}
19681965
else if (NCH(n) == 1) {
@@ -2047,8 +2044,7 @@ ast_for_comprehension(struct compiling *c, const node *n)
20472044

20482045
if (NCH(n) == 2) {
20492046
is_async = 1;
2050-
REQ(CHILD(n, 0), NAME);
2051-
assert(strcmp(STR(CHILD(n, 0)), "async") == 0);
2047+
REQ(CHILD(n, 0), ASYNC);
20522048
sync_n = CHILD(n, 1);
20532049
}
20542050
else {

0 commit comments

Comments
 (0)