diff --git a/CHANGELOG.md b/CHANGELOG.md index b0fd85d..3b5bc69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed * `wn.lmf` specifies `utf-8` when opening files ([#95]) +* `wn.lmf.dump()` casts attribute values to strings ## [v0.5.0] diff --git a/wn/lmf.py b/wn/lmf.py index 1c236e4..dfd8a7d 100644 --- a/wn/lmf.py +++ b/wn/lmf.py @@ -743,7 +743,9 @@ def _dump_lexicon(lexicon: Lexicon, out: TextIO, version: str) -> None: attrib['citation'] = lexicon.citation attrib.update(_meta_dict(lexicon.meta)) attrdelim = '\n' + (' ' * 11) - attrs = attrdelim.join(f'{attr}={quoteattr(val)}' for attr, val in attrib.items()) + attrs = attrdelim.join( + f'{attr}={quoteattr(str(val))}' for attr, val in attrib.items() + ) print(f' ', file=out) for entry in lexicon.lexical_entries: @@ -918,7 +920,9 @@ def _indent(elem: ET.Element, level: int) -> None: def _meta_dict(m: Optional[Metadata]) -> Dict: if m: - d = {f'dc:{key}': val for key, val in zip(m._fields, m) if val is not None} + d = {f'dc:{key}': str(val) + for key, val in zip(m._fields, m) + if val is not None} else: d = {} return d