Comment 2 for bug 1279977

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

The issue here is that the proxy types delegate calls to __str__ to the dbus types. dbus.Boolean's __str__ method prints booleans as '1' or '0'. In this case, the issue is that the print() function calls __str__, not __repr__.

We'll fix this in the types module, but it doesn't actually effect any functionality. The problem you were having originally was using 'is' vs '==' THis is highlighted with this ipython output:

---
In [1]: import dbus

In [2]: b1 = dbus.Boolean(True)

In [3]: b2 = True

In [4]: b1 is b2
Out[4]: False

In [5]: b1 == b2
Out[5]: True
---

Since the proxy type isn't actually a builtin boolean (it's a dbus boolean), using 'is' won't work. The repr/str issue is illustrated below:

---
In [7]: repr(b1)
Out[7]: 'dbus.Boolean(True)'

In [8]: str(b1)
Out[8]: '1'
---

Cheers,