Skip to content
Browse files

GenBank.Scanner: Raise ValueErrors instead of AssertionErrors when pa…

…rsing fails

Other parts of the parser code all raise ValueError()s when they
encounter unexpected input, just the checks for,
and record.description raise AssertionErrors. Fix this and provide more
meaningful error messages.

For, this code path can be triggered by a GenBank file with
the locus line of "LOCUS        \n".

Signed-off-by: Kai Blin <>
  • Loading branch information...
1 parent 7420310 commit fa41c9c029c303dd7c46dbb21c40b8cc497e94c0 @kblin kblin committed Jan 12, 2013
Showing with 6 additions and 3 deletions.
  1. +6 −3 Bio/GenBank/
9 Bio/GenBank/
@@ -457,9 +457,12 @@ def parse_records(self, handle, do_features=True):
record = self.parse(handle, do_features)
if record is None:
- assert is not None
- assert != "<unknown name>"
- assert record.description != "<unknown description>"
+ if is None:
+ raise ValueError("Failed to parse the record's ID. Invalid ID line?")
+ if == "<unknown name>":
+ raise ValueError("Failed to parse the record's name. Invalid ID line?")
+ if record.description == "<unknown description>":
+ raise ValueError("Failed to parse the record's description")
yield record
def parse_cds_features(self, handle,

0 comments on commit fa41c9c

Please sign in to comment.
Something went wrong with that request. Please try again.