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

Commit

Permalink
Fix some broken asserts relating to handling of async keyword (#92)
Browse files Browse the repository at this point in the history
typed_ast reintroduces ASYNC as a token after cpython 3.7 removed it.
Fix asserts that still wanted it to be a NAME.
  • Loading branch information
msullivan committed Feb 6, 2019
1 parent c6d7fcb commit 19d2c62
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions ast3/Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1820,8 +1820,7 @@ ast_for_async_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_se
{
/* async_funcdef: 'async' funcdef */
REQ(n, async_funcdef);
REQ(CHILD(n, 0), NAME);
assert(strcmp(STR(CHILD(n, 0)), "async") == 0);
REQ(CHILD(n, 0), ASYNC);
REQ(CHILD(n, 1), funcdef);

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

switch (TYPE(CHILD(n, 1))) {
case funcdef:
Expand Down Expand Up @@ -1961,8 +1959,7 @@ count_comp_fors(struct compiling *c, const node *n)
n_fors++;
REQ(n, comp_for);
if (NCH(n) == 2) {
REQ(CHILD(n, 0), NAME);
assert(strcmp(STR(CHILD(n, 0)), "async") == 0);
REQ(CHILD(n, 0), ASYNC);
n = CHILD(n, 1);
}
else if (NCH(n) == 1) {
Expand Down Expand Up @@ -2047,8 +2044,7 @@ ast_for_comprehension(struct compiling *c, const node *n)

if (NCH(n) == 2) {
is_async = 1;
REQ(CHILD(n, 0), NAME);
assert(strcmp(STR(CHILD(n, 0)), "async") == 0);
REQ(CHILD(n, 0), ASYNC);
sync_n = CHILD(n, 1);
}
else {
Expand Down

0 comments on commit 19d2c62

Please sign in to comment.