Commit 59546849 authored by Stefan Behnel's avatar Stefan Behnel

Fix a crash when compiling a module without statements, only a single declaration.

parent 2570b55e
......@@ -79,6 +79,13 @@ class NormalizeTree(CythonTransform):
self.is_in_statlist = False
self.is_in_expr = False
def visit_ModuleNode(self, node):
self.visitchildren(node)
if not isinstance(node.body, Nodes.StatListNode):
# This can happen when the body only consists of a single (unused) declaration and no statements.
node.body = Nodes.StatListNode(pos=node.pos, stats=[node.body])
return node
def visit_ExprNode(self, node):
stacktmp = self.is_in_expr
self.is_in_expr = True
......
# mode: compile
# tag: fused
# This previously lead to a crash due to an empty module body.
ctypedef fused cinteger:
int
long
Py_ssize_t
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment