diff --git a/data_elements.py b/data_elements.py index 937bf5b..01a130e 100644 --- a/data_elements.py +++ b/data_elements.py @@ -231,13 +231,13 @@ def delete_title(self, _): def editions(self): "Iterate over the children of the Chapters element, if any." elt = self.child_named('Chapters') - if elt is None: - raise StopIteration + if elt is None: return yield from elt.children_named('EditionEntry') @property def chapters(self): "Iterate over the ChapterAtom children of the first EditionEntry." - edition = next(self.editions) # May raise StopIteration + try: edition = next(self.editions) + except StopIteration: return yield from edition.chapters # Manipulating children diff --git a/tags.py b/tags.py index 8ff10af..7fb8b96 100644 --- a/tags.py +++ b/tags.py @@ -137,7 +137,8 @@ def __getitem__(self, key): return self._dict[key] except KeyError: if isinstance(key, int): - return Tag(key, 'Unknown', 'ElementUnsupported', "*", + from .element import ElementUnsupported + return Tag(key, 'Unknown', ElementUnsupported, "*", False, True, True, 1, 4) raise