[docs] [issue16057] Subclasses of JSONEncoder should not be insturcted to call JSONEncoder.decode
report at bugs.python.org
Fri Sep 28 22:23:02 CEST 2012
Justin Lebar added the comment:
Ah, I see. The examples do what you think they should do, but not for the reason you think they should do it -- the JSON encoding logic calls the encoder's encode() method before calling its default() method.
I still think the examples could be improved, perhaps by adding a comment to the effect of
# Raises a TypeError.
before the call to JSONEncoder.default(). Explicit is better than implicit, after all. :)
Thanks for looking at this.
Python tracker <report at bugs.python.org>
More information about the docs