Skip to content

Commit

Permalink
Break out of for loop when ; is encountered, and make sure that no to…
Browse files Browse the repository at this point in the history
…kens remain.
  • Loading branch information
bendmorris authored and etal committed Feb 10, 2013
1 parent 8e33a7a commit ef47292
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Bio/Phylo/NewickIO.py
Expand Up @@ -153,7 +153,7 @@ def _parse_tree(self, text):
entering_branch_length = False
rp_count += 1

elif token == ';': pass
elif token == ';': break

elif token.startswith(':'):
# branch length or confidence
Expand All @@ -171,6 +171,13 @@ def _parse_tree(self, text):

if not lp_count == rp_count:
raise NewickError('Number of open/close parentheses do not match.')

# if ; token broke out of for loop, there should be no remaining tokens
try:
next_token = tokens.next()
raise NewickError('Text after semicolon in Newick tree: %s' % next_token.group())
except StopIteration:
pass

self.process_clade(current_clade)
self.process_clade(root_clade)
Expand Down

0 comments on commit ef47292

Please sign in to comment.