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 rhettinger
Recipients anders.rundgren.net@gmail.com, bob.ippolito, ethan.furman, rhettinger
Date 2014-12-28.23:36:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1419809764.74.0.533133023627.issue23123@psf.upfronthosting.co.za>
In-reply-to
Content
It is unfortunate that there doesn't seem to be a way to round-trip Decimals.  That would seem to be a fundamental capability that we should expect to support.

I have a vague recollection that you used to be able to trick the encoder by returning a subclass of float with a custom __str__; however, I don't think that hack would work anymore because float subclasses now get coerced back to a regular float in order to make the json module work with Enums (which have a __str__ that is meaningless in JSON).

In Python 3.5, it would be nice to add a hook that affords more control than "cls" currently does.  Ideally, it should allow any class to special exactly what it wants written-out.

Another option, for Py2.7, 3.4, and 3.5 is to add direct support for decimal instances (much like the enum support was backported).
History
Date User Action Args
2014-12-28 23:36:04rhettingersetrecipients: + rhettinger, bob.ippolito, ethan.furman, anders.rundgren.net@gmail.com
2014-12-28 23:36:04rhettingersetmessageid: <1419809764.74.0.533133023627.issue23123@psf.upfronthosting.co.za>
2014-12-28 23:36:04rhettingerlinkissue23123 messages
2014-12-28 23:36:04rhettingercreate