Skip to content

Commit 1a0874e

Browse files
committed
bpo-39639: remove suite node
1 parent 1ed6161 commit 1a0874e

File tree

10 files changed

+7
-106
lines changed

10 files changed

+7
-106
lines changed

Doc/whatsnew/3.9.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,9 @@ Removed
554554
defining ``COUNT_ALLOCS`` macro.
555555
(Contributed by Victor Stinner in :issue:`39489`.)
556556

557+
* ``Suite`` node from :mod:`ast` has been removed due to it is no longer needed.
558+
(Contributed by Batuhan Taskaya in :issue:`39639`.)
559+
557560

558561
Porting to Python 3.9
559562
=====================

Include/Python-ast.h

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_asdl_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def visitConstructor(self, cons):
118118
v = CustomVisitor()
119119
v.visit(self.types['mod'])
120120
self.assertEqual(v.names_with_seq,
121-
['Module', 'Module', 'Interactive', 'FunctionType', 'Suite'])
121+
['Module', 'Module', 'Interactive', 'FunctionType'])
122122

123123

124124
if __name__ == '__main__':
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove ``Suite`` node from AST. Patch by Batuhan Taskaya.

Parser/Python.asdl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33

44
module Python
55
{
6-
mod = Module(stmt* body, type_ignore *type_ignores)
6+
mod = Module(stmt* body, type_ignore* type_ignores)
77
| Interactive(stmt* body)
88
| Expression(expr body)
99
| FunctionType(expr* argtypes, expr returns)
1010

11-
-- not really an actual node but useful in Jython's typesystem.
12-
| Suite(stmt* body)
13-
1411
stmt = FunctionDef(identifier name, arguments args,
1512
stmt* body, expr* decorator_list, expr? returns,
1613
string? type_comment)
@@ -51,7 +48,6 @@ module Python
5148
| Expr(expr value)
5249
| Pass | Break | Continue
5350

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

Python/Python-ast.c

Lines changed: 0 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/ast.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,6 @@ PyAST_Validate(mod_ty mod)
545545
case Expression_kind:
546546
res = validate_expr(mod->v.Expression.body, Load);
547547
break;
548-
case Suite_kind:
549-
PyErr_SetString(PyExc_ValueError, "Suite is not valid in the CPython compiler");
550-
break;
551548
default:
552549
PyErr_SetString(PyExc_SystemError, "impossible module node");
553550
res = 0;

Python/ast_opt.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,6 @@ astfold_mod(mod_ty node_, PyArena *ctx_, int optimize_)
462462
case Expression_kind:
463463
CALL(astfold_expr, expr_ty, node_->v.Expression.body);
464464
break;
465-
case Suite_kind:
466-
CALL_SEQ(astfold_stmt, stmt_ty, node_->v.Suite.body);
467-
break;
468465
default:
469466
break;
470467
}

Python/compile.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,10 +1862,6 @@ compiler_mod(struct compiler *c, mod_ty mod)
18621862
VISIT_IN_SCOPE(c, expr, mod->v.Expression.body);
18631863
addNone = 0;
18641864
break;
1865-
case Suite_kind:
1866-
PyErr_SetString(PyExc_SystemError,
1867-
"suite should not be possible");
1868-
return 0;
18691865
default:
18701866
PyErr_Format(PyExc_SystemError,
18711867
"module kind %d should not be possible",

Python/symtable.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,6 @@ PySymtable_BuildObject(mod_ty mod, PyObject *filename, PyFutureFeatures *future)
318318
(stmt_ty)asdl_seq_GET(seq, i)))
319319
goto error;
320320
break;
321-
case Suite_kind:
322-
PyErr_SetString(PyExc_RuntimeError,
323-
"this compiler does not handle Suites");
324-
goto error;
325321
case FunctionType_kind:
326322
PyErr_SetString(PyExc_RuntimeError,
327323
"this compiler does not handle FunctionTypes");

0 commit comments

Comments
 (0)