This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barry
Recipients barry
Date 2011-07-29.18:28:07
SpamBayes Score 8.565441e-06
Marked as misclassified No
Message-id <1311964088.32.0.0267577465373.issue12657@psf.upfronthosting.co.za>
In-reply-to
Content
I found this out while experimenting with enum types that inherit from int.  The json library provides for extending the encoder to handle non-basic types; in those cases, your class's .default() method is called.  However, it is impossible to override how basic types are encoded.

Worse, if you subclass int, you cannot override how instances of your subclass get encoded, because _iterencode() does isinstance() checks.  So enum values which subclass int cannot be properly encoded.

I think the isinstance checks should be changed to explicit type equality tests, e.g. `type(o) is int`.
History
Date User Action Args
2011-07-29 18:28:08barrysetrecipients: + barry
2011-07-29 18:28:08barrysetmessageid: <1311964088.32.0.0267577465373.issue12657@psf.upfronthosting.co.za>
2011-07-29 18:28:07barrylinkissue12657 messages
2011-07-29 18:28:07barrycreate