IATI/IATI-Stats

json.dump default for dictionaries with datetime objects is not working (Python upgrade)

Opened this issue · 1 comments

Part of #157
json.dump calls in aggregate.py are failing when trying to handle dictionaries that have datetime objects in them (appears to happen as both keys and values). https://github.com/IATI/IATI-Stats/blob/python-3-upgrade-wip/statsrunner/aggregate.py#L74
There is a decimal_default function that should be acting as a serializer, but it's currently not being called or defined properly, this should be fixed and applied to all its calls.

I think the problem here was introduced in ab4e52c.

In the python3 upgrade, instances of unicode(date) should have been replaced with str(date) in order to convert dates to strings. Instead, they were replaced with date, which then causes this problem when JSON encoding.