update json.dumps for http_date changes

This commit is contained in:
Grey Li 2021-02-25 09:42:44 -08:00 committed by David Lord
parent dcd3b5c8f8
commit 49b7341a49
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 12 additions and 17 deletions

View file

@ -3,7 +3,6 @@ import json as _json
import uuid
import warnings
from datetime import date
from datetime import datetime
from jinja2.utils import htmlsafe_json_dumps as _jinja_htmlsafe_dumps
from werkzeug.http import http_date
@ -41,10 +40,8 @@ class JSONEncoder(_json.JSONEncoder):
overriding how basic types like ``str`` or ``list`` are
serialized, they are handled before this method.
"""
if isinstance(o, datetime):
return http_date(o.utctimetuple())
if isinstance(o, date):
return http_date(o.timetuple())
return http_date(o)
if isinstance(o, uuid.UUID):
return str(o)
if dataclasses and dataclasses.is_dataclass(o):