From 837ff1a1ba39474790cf7e6110737bdfaec6b568 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Wed, 10 Jan 2024 15:53:15 +1300 Subject: [PATCH] Taxonomy: fixed an issue related to StopIteration behaviour in new versions of python --- python/obitools3/dms/taxo/taxo.pyx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/obitools3/dms/taxo/taxo.pyx b/python/obitools3/dms/taxo/taxo.pyx index d473d91..314f49f 100755 --- a/python/obitools3/dms/taxo/taxo.pyx +++ b/python/obitools3/dms/taxo/taxo.pyx @@ -325,8 +325,9 @@ cdef class Taxonomy(OBIWrapper) : cdef Taxon taxon try: taxon = self.get_taxon_by_taxid(taxid) - except: - raise StopIteration + except Exception as e: + print('\n'+e, file=sys.stderr) + return if taxon is not None: while taxon.taxid != 1: yield taxon @@ -334,7 +335,7 @@ cdef class Taxonomy(OBIWrapper) : taxon = taxon.parent yield taxon else: - raise StopIteration + return def is_ancestor(self, int ancestor_taxid, int taxid):