diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-03-18 01:52:35 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-03-18 01:52:35 (GMT) |
commit | dd246171e483afa21f12e2a961a461e0d5119ea3 (patch) | |
tree | c572c72b8406b9c3c5719286e7b4ebb773a8f47d /Doc | |
parent | f3460414d56500b8ff551515ac7fed78b49e33c9 (diff) | |
download | cpython-dd246171e483afa21f12e2a961a461e0d5119ea3.zip cpython-dd246171e483afa21f12e2a961a461e0d5119ea3.tar.gz cpython-dd246171e483afa21f12e2a961a461e0d5119ea3.tar.bz2 |
#16057: Clarify why the base method default is called in custom encoders.
Original patch by Kushal Das.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/json.rst | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 7b69c24..58eee18 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -83,6 +83,7 @@ Extending :class:`JSONEncoder`:: ... def default(self, obj): ... if isinstance(obj, complex): ... return [obj.real, obj.imag] + ... # Let the base class default method raise the TypeError ... return json.JSONEncoder.default(self, obj) ... >>> json.dumps(2 + 1j, cls=ComplexEncoder) @@ -431,6 +432,7 @@ Encoders and Decoders pass else: return list(iterable) + # Let the base class default method raise the TypeError return json.JSONEncoder.default(self, o) |