Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Ocre42 opened this issue May 23, 2019 · 1 comment

Comments

@Ocre42
Copy link
Contributor

Ocre42 commented May 23, 2019

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.

@andylolz
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants