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
If you pass in a dict and one of the values is an unsupported type (e.g. a datetime object), the code doesn't raise an exception - it just passes silently over the value without adding it to the XML output. Here's an example that produces the issue:
>>> import dict2xml
>>> import datetime
>>> now = datetime.datetime.today()
>>> mydict = { 'name': 'Joe Blow', 'time': now }
>>> xml = dict2xml.dict2xml(mydict)
>>> print xml
<?xml version="1.0" encoding="UTF-8" ?><root><name type="str">Joe Blow</name></root>
>>> # the 'time' key and its datetime value just silently disappeared
I propose the following fix:
Raise an exception in convert_dict() and convert_list() if one of the elements is an unsupported type (currently, only convert() raises an exception).
Include an optional parameter that will automatically convert datetimes into UTC strings in the XML output.
Include an optional parameter that will automatically convert other unsupported types into their string representations.
The text was updated successfully, but these errors were encountered:
Fixed in release 0.5. Now supports datetime (converts to ISO format string) and set (converts to list) data types, and raises a TypeError exception on an unsupported data type.
If you pass in a dict and one of the values is an unsupported type (e.g. a datetime object), the code doesn't raise an exception - it just passes silently over the value without adding it to the XML output. Here's an example that produces the issue:
I propose the following fix:
convert_dict()
andconvert_list()
if one of the elements is an unsupported type (currently, onlyconvert()
raises an exception).The text was updated successfully, but these errors were encountered: