Skip to content

Commit dc476db

Browse files
phorwarddiegorusso
authored andcommitted
doc: Use super() in subclassed JSONEncoder examples (pythonGH-115565)
Replace calls to `json.JSONEncoder.default(self, obj)` by `super().default(obj)` within the examples of the documentation.
1 parent 17215c5 commit dc476db

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Doc/library/json.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Extending :class:`JSONEncoder`::
106106
... if isinstance(obj, complex):
107107
... return [obj.real, obj.imag]
108108
... # Let the base class default method raise the TypeError
109-
... return json.JSONEncoder.default(self, obj)
109+
... return super().default(obj)
110110
...
111111
>>> json.dumps(2 + 1j, cls=ComplexEncoder)
112112
'[2.0, 1.0]'
@@ -504,7 +504,7 @@ Encoders and Decoders
504504
else:
505505
return list(iterable)
506506
# Let the base class default method raise the TypeError
507-
return json.JSONEncoder.default(self, o)
507+
return super().default(o)
508508

509509

510510
.. method:: encode(o)

Lib/json/encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def default(self, o):
174174
else:
175175
return list(iterable)
176176
# Let the base class default method raise the TypeError
177-
return JSONEncoder.default(self, o)
177+
return super().default(o)
178178
179179
"""
180180
raise TypeError(f'Object of type {o.__class__.__name__} '

0 commit comments

Comments
 (0)