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 mark.dickinson
Recipients eajames, eric.smith, mark.dickinson, r.david.murray
Date 2016-09-02.15:38:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1472830696.08.0.88306181654.issue27934@psf.upfronthosting.co.za>
In-reply-to
Content
> 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 to the 2.7 branch does require making a case that it's a bugfix rather than a new feature (which isn't permitted in 2.7), *and* that it's not going to cause gratuitous breakage in existing json-using applications. I think there *is* a reasonable case there, but others may disagree. One point in its favour is that we're *already* behaving like a regular float for special values:

Python 2.7.12 (default, Jun 29 2016, 12:46:54) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus, json
>>> x = dbus.Double(float('inf'))
>>> json.dumps(x)  # not using repr(x) here
'Infinity'
>>> repr(x)
'dbus.Double(inf)'
>>> x = dbus.Double(2.3)
>>> json.dumps(x)  # using repr(x) here
'dbus.Double(2.3)'
>>> repr(x)
'dbus.Double(2.3)'
History
Date User Action Args
2016-09-02 15:38:16mark.dickinsonsetrecipients: + mark.dickinson, eric.smith, r.david.murray, eajames
2016-09-02 15:38:16mark.dickinsonsetmessageid: <1472830696.08.0.88306181654.issue27934@psf.upfronthosting.co.za>
2016-09-02 15:38:16mark.dickinsonlinkissue27934 messages
2016-09-02 15:38:16mark.dickinsoncreate