Skip to content

Commit 66d055a

Browse files
author
Hobson Lane
committed
gitignore .pyc and fix vistory.py to not fail when no node children
1 parent 6e48015 commit 66d055a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pyc
2+
*.egg-info

java2python/compiler/visitor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)