JSON serializer imporperly serializes: datetime.datetime, datetime.time, float
|Reported by:||pigletto||Owned by:||nobody|
|Has patch:||yes||Needs documentation:|
|Needs tests:||Patch needs improvement:|
This bug was introduced after commiting patch for this ticket: http://code.djangoproject.com/ticket/4714
Original patch I've written was changed by commiter and this introduced some issues.
Problem is that now serializers/python.py uses smart_unicode(... , strings_only=True).
Unfortunatelly smart_unicode only recogizes None, int and long as not strings.
Because of this, datetime objects (as well as floats) are converted to strings.
This causes that serializers/json.py -> DjangoJSONEncoder is useless.
My, original implementation from #4714, uses function 'str_to_unicode' that converts only
instances of basestring to unicode - so it works properly.
I'm not sure why it was changed to 'smart_unicode', but if 'smart_unicode' should be used then
'force_unicodes detection of strings has to be changed.
Problem is with datetime.datetime, datetime.time, float and possibly Decimal.
I've attached a patch with tests.