[3.12] doc: Use super() in subclassed JSONEncoder examples (GH-115565) (GH-116047)

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.
(cherry picked from commit 647053fed1)

Co-authored-by: Jan Max Meyer <jmm@phorward.de>
This commit is contained in:
Miss Islington (bot) 2024-02-28 15:13:08 +01:00 committed by GitHub
parent e5e98626a1
commit 9df6d1e033
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -95,7 +95,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]'
@ -493,7 +493,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)

View file

@ -174,7 +174,7 @@ def default(self, o):
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__} '