Merge pull request #19413 from gavindsouza/build_response-json

fix: build_response for re.Match
This commit is contained in:
Ritwik Puri 2022-12-31 00:06:34 +05:30 committed by GitHub
commit 7cae422a8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -159,6 +159,7 @@ def make_logs(response=None):
def json_handler(obj):
"""serialize non-serializable data for json"""
from collections.abc import Iterable
from re import Match
if isinstance(obj, (datetime.date, datetime.datetime, datetime.time)):
return str(obj)
@ -179,6 +180,9 @@ def json_handler(obj):
elif isinstance(obj, Iterable):
return list(obj)
elif isinstance(obj, Match):
return obj.string
elif type(obj) == type or isinstance(obj, Exception):
return repr(obj)