Skip to content

Commit

Permalink
fix: handle python builtins and keywords during as_xml() for attrib…
Browse files Browse the repository at this point in the history
…utes

Signed-off-by: Paul Horton <paul.horton@owasp.org>
  • Loading branch information
madpah committed Aug 26, 2022
1 parent 6520862 commit 8d6a96b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion serializable/__init__.py
Expand Up @@ -30,7 +30,7 @@
from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Type, TypeVar, Union, cast
from xml.etree import ElementTree

from .formatters import CurrentFormatter
from .formatters import CurrentFormatter, BaseNameFormatter
from .helpers import BaseHelper

logger = logging.getLogger('serializable')
Expand Down Expand Up @@ -239,6 +239,7 @@ def _as_xml(self: _T, as_string: bool = True, element_name: Optional[str] = None
new_key = k[1:]
if new_key.startswith('_') or '__' in new_key:
continue
new_key = BaseNameFormatter.decode_handle_python_builtins_and_keywords(name=new_key)

# Ignore Nones
if not v:
Expand Down

0 comments on commit 8d6a96b

Please sign in to comment.