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.14:44:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1472827444.67.0.205056055676.issue27934@psf.upfronthosting.co.za>
In-reply-to
Content
> 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(<value>, float`) check.

I don't know dbus at all, but I just tried installing it under Macports (on OS X 10.9). Here's the package description, so you can tell me whether I'm actually installing the right thing, or something totally unrelated:

    dbus-python35 @1.2.0_2 (devel, python)
        Python bindings for the dbus message bus system.

Once I've done that, I get the following behaviour in Python:

Python 3.5.2 (default, Aug 16 2016, 08:43:53) 
[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
>>> dbus.Double
<class 'dbus.Double'>
>>> dbus.Double.__mro__
(<class 'dbus.Double'>, <class '_dbus_bindings._FloatBase'>, <class 'float'>, <class 'object'>)

So it looks as though at least for this version of dbus, we do have a subclass of `float`. Looking at an instance, I see the following:

>>> x = dbus.Double(4.3)
>>> isinstance(x, float)
True
>>> repr(x)
'dbus.Double(4.3)'
>>> str(x)
'4.3'
>>> float.__repr__(x)
'4.3'
>>> float.__str__(x)
'4.3'
>>> import json
>>> json.dumps(x)
'4.3'

So I'm still struggling to see what difference swapping out float.__repr__ for float.__str__ would make.
History
Date User Action Args
2016-09-02 14:44:04mark.dickinsonsetrecipients: + mark.dickinson, eric.smith, r.david.murray, eajames
2016-09-02 14:44:04mark.dickinsonsetmessageid: <1472827444.67.0.205056055676.issue27934@psf.upfronthosting.co.za>
2016-09-02 14:44:04mark.dickinsonlinkissue27934 messages
2016-09-02 14:44:04mark.dickinsoncreate