Skip default fallback logic when cls
is specified
`cls` will provide its own default serialization mechanism, passing a `cls` Encoder class is now also a way to opt-out of our patching shenanigans and just use your own code. This will work, provided the library doing the JSON encoding isn't also using their own custom class.
This commit is contained in:
parent
726c70d01e
commit
6f3b550e88
@ -3729,6 +3729,7 @@ def _json_dumps_wrapper(*args, **kwargs):
|
||||
Returns:
|
||||
The JSON string.
|
||||
"""
|
||||
if "cls" not in kwargs:
|
||||
_orig_default = kwargs.pop("default", None)
|
||||
|
||||
def _default(obj):
|
||||
@ -3743,6 +3744,7 @@ def _json_dumps_wrapper(*args, **kwargs):
|
||||
pass
|
||||
raise TypeError()
|
||||
|
||||
if "cls" not in kwargs:
|
||||
kwargs["default"] = _default
|
||||
return _orig_json_dumps(*args, **kwargs)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user