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 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)'

----------
versions:  -Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27934>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to