Message141406
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`. |
|
Date |
User |
Action |
Args |
2011-07-29 18:28:08 | barry | set | recipients:
+ barry |
2011-07-29 18:28:08 | barry | set | messageid: <1311964088.32.0.0267577465373.issue12657@psf.upfronthosting.co.za> |
2011-07-29 18:28:07 | barry | link | issue12657 messages |
2011-07-29 18:28:07 | barry | create | |
|