On Thu, Aug 15, 2019 at 2:23 AM Random832 <random...@fastmail.com> wrote:
>
> On Sun, Aug 11, 2019, at 20:42, Chris Angelico wrote:
> > class float:
> >     def __json__(self):
> >         if math.isfinite(self): return str(self)
> >         return "null"
>
> Er, to be clear, the current JSON decoder returns 'Infinity', '-Infinity', or 
> 'NaN', which are invalid JSON, not null. This behavior (vs raising an 
> exception) is governed by a flag. I'm mainly bringing this up to point out 
> that the concerns about a raw protocol being able to generate invalid JSON 
> seem somewhat overblown and that "people should be able to generate invalid 
> JSON if they want to" is not without precedent.
>

The examples I gave were meant to be toys, but you're right, this
doesn't match current behaviour. For an actual PEP it would be better
to be more accurate to the way json.dumps currently works; for this, I
didn't really care too much :)

Side point: Does anyone else think it was an egotistical idea to
create JSON as a non-versioned specification? "I can't possibly get
this wrong". And now look what's happened.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/HADNVZXOCRWE5VS2A7URIGXBZRMWUIZJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to