Taxonomy: fixed an issue related to StopIteration behaviour in new

versions of python
This commit is contained in:
Celine Mercier
2024-01-10 15:53:15 +13:00
parent aeed42456a
commit 837ff1a1ba

View File

@ -325,8 +325,9 @@ cdef class Taxonomy(OBIWrapper) :
cdef Taxon taxon cdef Taxon taxon
try: try:
taxon = self.get_taxon_by_taxid(taxid) taxon = self.get_taxon_by_taxid(taxid)
except: except Exception as e:
raise StopIteration print('\n'+e, file=sys.stderr)
return
if taxon is not None: if taxon is not None:
while taxon.taxid != 1: while taxon.taxid != 1:
yield taxon yield taxon
@ -334,7 +335,7 @@ cdef class Taxonomy(OBIWrapper) :
taxon = taxon.parent taxon = taxon.parent
yield taxon yield taxon
else: else:
raise StopIteration return
def is_ancestor(self, int ancestor_taxid, int taxid): def is_ancestor(self, int ancestor_taxid, int taxid):