@@ -440,7 +440,7 @@ def acceptFor(self, node, memo):
440440 else :
441441 whileStat .expr .walk (cond , memo )
442442 whileBlock = self .factory .methodContent (parent = self )
443- if not node .firstChildOfType (tokens .BLOCK_SCOPE ).children :
443+ if not node .firstChildOfType (tokens .BLOCK_SCOPE ) or not node . firstChildOfType ( tokens . BLOCK_SCOPE ) .children :
444444 self .factory .expr (left = 'pass' , parent = whileBlock )
445445 else :
446446 whileBlock .walk (node .firstChildOfType (tokens .BLOCK_SCOPE ), memo )
@@ -512,7 +512,7 @@ def acceptSwitch(self, node, memo):
512512 lblNode = node .firstChildOfType (tokens .SWITCH_BLOCK_LABEL_LIST )
513513 caseNodes = lblNode .children
514514 # empty switch statement
515- if not len ( caseNodes ) :
515+ if not caseNodes :
516516 return
517517 # we have at least one node...
518518 parExpr = self .factory .expr (parent = self )
@@ -535,7 +535,7 @@ def acceptSwitch(self, node, memo):
535535 caseContent = self .factory .methodContent (parent = self )
536536 for child in caseNode .children [1 :]:
537537 caseContent .walk (child , memo )
538- if not caseNode .children [1 :]:
538+ if not caseNode .children or not caseNode . children [1 :]:
539539 self .factory .expr (left = 'pass' , parent = caseContent )
540540 if isDefault :
541541 if isFirst :
@@ -607,7 +607,7 @@ def acceptWhile(self, node, memo):
607607 parNode , blkNode = node .children
608608 whileStat = self .factory .statement ('while' , fs = FS .lsrc , parent = self )
609609 whileStat .expr .walk (parNode , memo )
610- if not blkNode .children :
610+ if not blkNode or not blkNode .children :
611611 self .factory .expr (left = 'pass' , parent = whileStat )
612612 else :
613613 whileStat .walk (blkNode , memo )
0 commit comments