Merge pull request #19413 from gavindsouza/build_response-json
fix: build_response for re.Match
This commit is contained in:
commit
7cae422a8e
1 changed files with 4 additions and 0 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue