Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ete4/parser/newick.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def read_props(str text, long pos, is_leaf, dict parser, check_req=False):
except (AssertionError, ValueError) as e:
raise NewickError('parsing %r: %s' % (p0_str, e))

p1_str = '' # always defined (like p0_str) so error messages don't fail
try:
if pos < len(text) and text[pos] == ':':
pos = skip_spaces_and_comments(text, pos+1)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ def test_newick_formats(self):
# unsupported newick stream
self.assertRaises(Exception, Tree, [1,2,3])

def test_newick_missing_required_value(self):
# A strict parser with a required second field (dist/support) must
# raise a clean NewickError when that value is missing, not crash with
# UnboundLocalError from the error handler (issue #799).
self.assertRaises(NewickError, Tree, '(A);', parser=3)

def test_newick_multisupport(self):
nw = '((a,b)2/3:4,(c,d)5/6:7);'
t = Tree(nw, parser='multisupport')
Expand Down