summaryrefslogtreecommitdiff
path: root/Doc/library/json.rst
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-03-17 22:06:18 -0400
committerR David Murray <rdmurray@bitdance.com>2013-03-17 22:06:18 -0400
commit35893b799496c8a9d118e64b49f10ac9bf369760 (patch)
treeba99bd751ea4e1d08d524b2a9f316b28d37075c6 /Doc/library/json.rst
parent271e56e88740cdcc2a6bddbd0894aec25f984f4e (diff)
downloadcpython-git-35893b799496c8a9d118e64b49f10ac9bf369760.tar.gz
#16057: Clarify why the base method default is called in custom encoders.
Original patch by Kushal Das.
Diffstat (limited to 'Doc/library/json.rst')
-rw-r--r--Doc/library/json.rst2
1 files changed, 2 insertions, 0 deletions
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index 648ba3a788..a3c6bb0efb 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -84,6 +84,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)
...
>>> dumps(2 + 1j, cls=ComplexEncoder)
@@ -452,6 +453,7 @@ Encoders and Decoders
pass
else:
return list(iterable)
+ # Let the base class default method raise the TypeError
return JSONEncoder.default(self, o)