You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
XmlParser saves 'None' as value for an empty node (i.e. a node that has neither attributes nor sub-nodes).
It should, though, better save an empty dict as value.
Background:
None is not iterable. A dict, though, would still evaluate to False if empty but stays iterable.
With None, Python code such as the following will cause an exception:
if '_attributes' in my_parsed_xml_dict[node_key]:
because my_parsed_xml_dict[node_key] is None.
If my_parsed_xml_dict[node_key] would be an empty dict, i.e. {}, the above code would still evaluate to False, but not crash.
The text was updated successfully, but these errors were encountered:
…empty node is now saved as an empty dict, i.e. {}, instead of None.
This change solves issue #4.
Problem was that None is not iterable, and code such as the following had caused an exception:
if '_attributes' in my_parsed_xml_dict[node_key]:
...
because my_parsed_xml_dict[node_key] had been None.
Now, with this code change in place, my_parsed_xml_dict[node_key] would resolve not anylonger to None but to an empty dict ( {} ). As the dict is formally iterable (even when empty), above code does not crash.
XmlParser saves 'None' as value for an empty node (i.e. a node that has neither attributes nor sub-nodes).
It should, though, better save an empty dict as value.
Background:
None is not iterable. A dict, though, would still evaluate to False if empty but stays iterable.
With None, Python code such as the following will cause an exception:
because my_parsed_xml_dict[node_key] is None.
If my_parsed_xml_dict[node_key] would be an empty dict, i.e. {}, the above code would still evaluate to False, but not crash.
The text was updated successfully, but these errors were encountered: