Skip to content

Commit

Permalink
Extend content exceptions in group encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
brunato committed May 21, 2022
1 parent 711c4d2 commit 6f86ea5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion xmlschema/validators/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ def iter_encode(self, obj: ElementData, validation: str = 'lax', **kwargs: Any)
over_max_depth = 'max_depth' in kwargs and kwargs['max_depth'] <= level

content: Iterable[Any]
if obj.content is None:
if not obj.content:
content = []
elif isinstance(obj.content, MutableMapping) or kwargs.get('unordered'):
content = ModelVisitor(self).iter_unordered_content(
Expand All @@ -1151,6 +1151,12 @@ def iter_encode(self, obj: ElementData, validation: str = 'lax', **kwargs: Any)
elif not isinstance(obj.content, MutableSequence):
wrong_content_type = True
content = []
elif not isinstance(obj.content[0], tuple):
if len(obj.content) > 1 or text is not None:
wrong_content_type = True
else:
text = raw_xml_encode(obj.content[0])
content = []
elif converter.losslessly:
content = obj.content
else:
Expand Down

0 comments on commit 6f86ea5

Please sign in to comment.