From 9843b3a101f5efb8050a0141fd3f63dbb7c9f8d7 Mon Sep 17 00:00:00 2001 From: Chris Angelico Date: Mon, 27 Jun 2022 11:06:21 +1000 Subject: [PATCH 1/2] Refer to Unsupported by type not by name Unsupported entities crash in trying to refer to their element tags. --- tags.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 2b39cd972d780b6dabaceb19b560f28b9062363d Mon Sep 17 00:00:00 2001 From: Chris Angelico Date: Mon, 27 Jun 2022 11:15:26 +1000 Subject: [PATCH 2/2] Fix generators to be PEP 479 compatible. This has no impact on the operation in pre-Py3.5 versions, and fixes the failures in Python 3.7 and later (when generator_stop became mandatory). --- data_elements.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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