summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/json.rst2
-rw-r--r--Lib/json/encoder.py1
2 files changed, 3 insertions, 0 deletions
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index 758ebd4..9bafcfe 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -82,6 +82,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)
@@ -426,6 +427,7 @@ Encoders and Decoders
pass
else:
return list(iterable)
+ # Let the base class default method raise the TypeError
return json.JSONEncoder.default(self, o)
diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py
index 93b5ea7..39b550d 100644
--- a/Lib/json/encoder.py
+++ b/Lib/json/encoder.py
@@ -166,6 +166,7 @@ class JSONEncoder(object):
pass
else:
return list(iterable)
+ # Let the base class default method raise the TypeError
return JSONEncoder.default(self, o)
"""