#16057: Clarify why the base method default is called in custom encoders.
Original patch by Kushal Das.
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index 648ba3a..a3c6bb0 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -84,6 +84,7 @@
... 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 @@
pass
else:
return list(iterable)
+ # Let the base class default method raise the TypeError
return JSONEncoder.default(self, o)