[issue27934] json float encoding incorrect for dbus.Double

2018-09-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Agreed. It is too late. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe

[issue27934] json float encoding incorrect for dbus.Double

2018-09-25 Thread Mark Dickinson
Mark Dickinson added the comment: [Serhiy] > I have doubts about breaking it in a bugfix release of 2.7. Yes, possibly we shouldn't have changed this (though it's a fairly horrible trick, IMO). I don't think it would be a good idea to revert the change at this point, though. -- __

[issue27934] json float encoding incorrect for dbus.Double

2018-09-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This change broke a trick used for serializing Decimal to JSON without loss (see msg176158). It was good to break it in a new release, but I have doubts about breaking it in a bugfix release of 2.7. -- nosy: +serhiy.storchaka _

[issue27934] json float encoding incorrect for dbus.Double

2016-09-03 Thread Mark Dickinson
Changes by Mark Dickinson : -- resolution: -> fixed stage: needs patch -> resolved status: open -> closed ___ Python tracker ___ ___

[issue27934] json float encoding incorrect for dbus.Double

2016-09-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 86d66a627b77 by Mark Dickinson in branch '2.7': Issue #27934: Use float.__repr__ instead of plain repr when JSON-encoding an instance of a float subclass. Thanks Eddie James. https://hg.python.org/cpython/rev/86d66a627b77 -- nosy: +python-d

[issue27934] json float encoding incorrect for dbus.Double

2016-09-03 Thread Mark Dickinson
Changes by Mark Dickinson : -- assignee: -> mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: htt

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson
Mark Dickinson added the comment: Note that this will also change the results for JSON output of NumPy float64 values, so at the very least I'd expect this change to break (admittedly poorly written) unit tests / doctests. Python 2.7.12 (default, Jul 10 2016, 18:28:23) [GCC 4.2.1 Compatible A

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson
Mark Dickinson added the comment: Yes. I'm fairly convinced about the bug part; it's the gratuitous breakage part that worries me. It wouldn't surprise me at all to find that there's someone out there who wants all their numbers to be written out to JSON with exactly 6 places after the point,

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eddie James
Changes by Eddie James : Added file: http://bugs.python.org/file44349/json-float-repr-2.7.patch ___ Python tracker ___ ___ Python-bugs-list ma

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eddie James
Eddie James added the comment: Python 2.7 also already behaves correctly for other dbus types: Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import dbus >>> import json >>> x = dbus.Int32(3) >>> x d

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson
Mark Dickinson added the comment: > That's still using PyObject_Repr() which will call tp_repr for dbus.Double... > Any suggestions? Right, you'll want to replace that with a call to `PyFloat_Type.tp_repr(obj)`, as in the Python 3 code. We're in a bit of a grey area here: making this change t

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread R. David Murray
Changes by R. David Murray : -- resolution: third party -> stage: resolved -> needs patch status: closed -> open ___ Python tracker ___ _

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eddie James
Eddie James added the comment: Wait what about the json C code for 2.7? That's still using PyObject_Repr() which will call tp_repr for dbus.Double... Any suggestions? -- ___ Python tracker

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eddie James
Eddie James added the comment: Thanks Mark, yes you installed the right package. OK I didn't dig deep enough in the sub class. And yea, there shouldn't be any difference between float.__repr__ and float.__str__. Obviously repr calls the object's tp_repr method, while float.__repr__ calls the b

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson
Mark Dickinson added the comment: > Nothing that can/should be done on the stdlib side, then. I think there's nothing to do for 3.x: as far as I can tell, everything should be working exactly as desired there. For 2.7, we may want to consider processing float instances using `float.__repr__`

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson
Mark Dickinson added the comment: > Dbus.Double is not a subclass of float unfortunately. Okay, now I'm *really* confused. :-) If it's not a subclass of `float`, then how do you end up in the `floatstr` code? Every path to that code that I can see in the source is via an `isinstance(, float`)

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread R. David Murray
R. David Murray added the comment: Nothing that can/should be done on the stdlib side, then. -- nosy: +r.david.murray resolution: -> third party stage: -> resolved status: open -> closed ___ Python tracker __

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eddie James
Eddie James added the comment: Understood on 2.7, I wasn't aware it would cause any issues. Dbus.Double is not a subclass of float unfortunately. Problem is that all Dbus types seem to have a custom tp_repr method that returns that strange formatting I mentioned. So repr won't be the same as s

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eric V. Smith
Changes by Eric V. Smith : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson
Mark Dickinson added the comment: > I propose a change to use str() for float objects as well. This could be > ported back to 2.7 as well That would be a behaviour change for 2.7, and an undesirable one. `str` loses precision in Python 2, so e.g., `json.loads(json.dumps(pi)) == pi` would no l

[issue27934] json float encoding incorrect for dbus.Double

2016-09-01 Thread Eddie James
Changes by Eddie James : Added file: http://bugs.python.org/file44334/json-float-str-2.7.patch ___ Python tracker ___ ___ Python-bugs-list mai

[issue27934] json float encoding incorrect for dbus.Double

2016-09-01 Thread Eddie James
New submission from Eddie James: JSON does not correctly encode dbus.Double types, even though all other dbus types are handled fine. I end up with output like this (0.25 is the floating point value): dbus.Double(0.25, variant_level=1) Found that the encoding uses repr() for float objects but