Skip to content

Commit be59b21

Browse files
committed
patch: fix NoneType error for 'visit_Case' function in c_generator.py when a case is empty by adding none type checker
1 parent ab00af8 commit be59b21

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pycparser/c_generator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,9 @@ def visit_Switch(self, n):
305305

306306
def visit_Case(self, n):
307307
s = 'case ' + self.visit(n.expr) + ':\n'
308-
for stmt in n.stmts:
309-
s += self._generate_stmt(stmt, add_indent=True)
308+
if n.stmts is not None :
309+
for stmt in n.stmts:
310+
s += self._generate_stmt(stmt, add_indent=True)
310311
return s
311312

312313
def visit_Default(self, n):

0 commit comments

Comments
 (0)