[issue18264] enum.IntEnum is not compatible with JSON serialisation

Guido van Rossum report at bugs.python.org
Sat Jun 22 04:49:12 CEST 2013


Guido van Rossum added the comment:

Change json to call int() first.

--Guido van Rossum (sent from Android phone)
On Jun 21, 2013 7:45 PM, "Eli Bendersky" <report at bugs.python.org> wrote:

>
> Eli Bendersky added the comment:
>
> On Fri, Jun 21, 2013 at 6:59 PM, Barry A. Warsaw <report at bugs.python.org
> >wrote:
>
> >
> > Barry A. Warsaw added the comment:
> >
> > On Jun 22, 2013, at 01:08 AM, Nick Coghlan wrote:
> >
> > >Can I vote for something like "__builtin__" as the protocol, rather than
> > >something entirely specific to serialisation? As in "return the most
> > >appropriate builtin type with the same value"? Then a converter
> > >("operator.builtin"?) could coerce builtin subclasses to their base
> > classes
> > >by default, rather than needing to implement the protocol on every type.
> >
> > Such a protocol needs a way to deserialize as well.  You can't
> necessarily
> > assume (or shouldn't impose) that the __init__() can do that conversion.
> >  In
> > any case...
> >
> > >Such a design would need a PEP, of course.
> >
> > ...yes, definitely.
>
> Practically speaking, what should be done to make enum play well with JSON
> without writing new PEPs? I think we still want to convert those stdlib
> constants to IntEnums...
>
> Eli
>
> ----------
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue18264>
> _______________________________________
>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18264>
_______________________________________


More information about the Python-bugs-list mailing list