Skip to content

bpo-39639: remove suite node #18513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,9 @@ Removed
defining ``COUNT_ALLOCS`` macro.
(Contributed by Victor Stinner in :issue:`39489`.)

* The ``ast.Suite`` node class has been removed due to no longer being needed.
(Contributed by Batuhan Taskaya in :issue:`39639`.)


Porting to Python 3.9
=====================
Expand Down
8 changes: 1 addition & 7 deletions Include/Python-ast.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Lib/test/test_asdl_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def visitConstructor(self, cons):
v = CustomVisitor()
v.visit(self.types['mod'])
self.assertEqual(v.names_with_seq,
['Module', 'Module', 'Interactive', 'FunctionType', 'Suite'])
['Module', 'Module', 'Interactive', 'FunctionType'])


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove ``ast.Suite`` node class because it's no longer used. Patch by Batuhan Taskaya.
6 changes: 1 addition & 5 deletions Parser/Python.asdl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@

module Python
{
mod = Module(stmt* body, type_ignore *type_ignores)
mod = Module(stmt* body, type_ignore* type_ignores)
| Interactive(stmt* body)
| Expression(expr body)
| FunctionType(expr* argtypes, expr returns)

-- not really an actual node but useful in Jython's typesystem.
| Suite(stmt* body)

stmt = FunctionDef(identifier name, arguments args,
stmt* body, expr* decorator_list, expr? returns,
string? type_comment)
Expand Down Expand Up @@ -51,7 +48,6 @@ module Python
| Expr(expr value)
| Pass | Break | Continue

-- XXX Jython will be different
-- col_offset is the byte offset in the utf8 string the parser uses
attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)

Expand Down
79 changes: 0 additions & 79 deletions Python/Python-ast.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,6 @@ PyAST_Validate(mod_ty mod)
case Expression_kind:
res = validate_expr(mod->v.Expression.body, Load);
break;
case Suite_kind:
PyErr_SetString(PyExc_ValueError, "Suite is not valid in the CPython compiler");
break;
default:
PyErr_SetString(PyExc_SystemError, "impossible module node");
res = 0;
Expand Down
3 changes: 0 additions & 3 deletions Python/ast_opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,6 @@ astfold_mod(mod_ty node_, PyArena *ctx_, int optimize_)
case Expression_kind:
CALL(astfold_expr, expr_ty, node_->v.Expression.body);
break;
case Suite_kind:
CALL_SEQ(astfold_stmt, stmt_ty, node_->v.Suite.body);
break;
default:
break;
}
Expand Down
4 changes: 0 additions & 4 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1862,10 +1862,6 @@ compiler_mod(struct compiler *c, mod_ty mod)
VISIT_IN_SCOPE(c, expr, mod->v.Expression.body);
addNone = 0;
break;
case Suite_kind:
PyErr_SetString(PyExc_SystemError,
"suite should not be possible");
return 0;
default:
PyErr_Format(PyExc_SystemError,
"module kind %d should not be possible",
Expand Down
4 changes: 0 additions & 4 deletions Python/symtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,6 @@ PySymtable_BuildObject(mod_ty mod, PyObject *filename, PyFutureFeatures *future)
(stmt_ty)asdl_seq_GET(seq, i)))
goto error;
break;
case Suite_kind:
PyErr_SetString(PyExc_RuntimeError,
"this compiler does not handle Suites");
goto error;
case FunctionType_kind:
PyErr_SetString(PyExc_RuntimeError,
"this compiler does not handle FunctionTypes");
Expand Down