Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Break out of for loop when ; is encountered, and make sure that no to…

…kens remain.
  • Loading branch information...
commit ef472924fb34be6eb7978d2d1de2dee23910682a 1 parent 8e33a7a
@bendmorris bendmorris authored etal committed
Showing with 8 additions and 1 deletion.
  1. +8 −1 Bio/Phylo/NewickIO.py
View
9 Bio/Phylo/NewickIO.py
@@ -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
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.