[Python-ideas] Enums

Barry Warsaw barry at python.org
Thu Jul 28 19:46:52 CEST 2011


On Jul 28, 2011, at 10:57 AM, Ethan Furman wrote:

>Barry Warsaw wrote:
>> In my experimental branch I've also made EnumValues subclasses of ints.  This
>> breaks one test in my Mailman 3 test suite, since I was using a custom encoder
>> for json.dumps() which knew how to encode EnumValues.  However, the json
>> module doesn't allow you to override the encoding of basic types,
>
>Isn't this a problem with json?  An EnumValue is a subclass, after all, not a
>plain ol' straight-up int -- I would think that json should realize a
>subclass may be different and go the .default() route.

On first blush, I'd agree.  _iterencode() just does an isinstance check, which
is why this gets caught in the trap.

-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110728/9e4b1665/attachment.pgp>


More information about the Python-ideas mailing list