mirror of https://github.com/python/cpython
doc: Use super() in subclassed JSONEncoder examples (GH-115565)
Replace calls to `json.JSONEncoder.default(self, obj)` by `super().default(obj)` within the examples of the documentation.
This commit is contained in:
parent
449c6da2bd
commit
647053fed1
|
@ -106,7 +106,7 @@ Extending :class:`JSONEncoder`::
|
|||
... if isinstance(obj, complex):
|
||||
... return [obj.real, obj.imag]
|
||||
... # Let the base class default method raise the TypeError
|
||||
... return json.JSONEncoder.default(self, obj)
|
||||
... return super().default(obj)
|
||||
...
|
||||
>>> json.dumps(2 + 1j, cls=ComplexEncoder)
|
||||
'[2.0, 1.0]'
|
||||
|
@ -504,7 +504,7 @@ Encoders and Decoders
|
|||
else:
|
||||
return list(iterable)
|
||||
# Let the base class default method raise the TypeError
|
||||
return json.JSONEncoder.default(self, o)
|
||||
return super().default(o)
|
||||
|
||||
|
||||
.. method:: encode(o)
|
||||
|
|
|
@ -174,7 +174,7 @@ class JSONEncoder(object):
|
|||
else:
|
||||
return list(iterable)
|
||||
# Let the base class default method raise the TypeError
|
||||
return JSONEncoder.default(self, o)
|
||||
return super().default(o)
|
||||
|
||||
"""
|
||||
raise TypeError(f'Object of type {o.__class__.__name__} '
|
||||
|
|
Loading…
Reference in New Issue