Boolean properties reported as 0/1 but pretty-printed True/False in get_properties

Bug #1279977 reported by Allan LeSage
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Autopilot
Fix Released
Medium
Unassigned
autopilot (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Discovered that boolean properties may be reported as 0 or 1, however pretty-printed as True or False in the get_properties dict; thomi believes this may be a bug in the deeper dbus interface, will attach a case.

Related branches

Revision history for this message
Allan LeSage (allanlesage) wrote :
Changed in autopilot:
status: New → In Progress
assignee: nobody → Thomi Richards (thomir)
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,

Revision history for this message
Allan LeSage (allanlesage) wrote :

Ninjas don't care about cosmetics! (Don't show under the mask.)

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package autopilot - 1.4+14.04.20140303-0ubuntu1

---------------
autopilot (1.4+14.04.20140303-0ubuntu1) trusty; urgency=low

  [ Thomi Richards ]
  * Prepare functional tests so that they can run on a device (Skips any
    that cannot run on a device).
  * Make proxy object attributes look more pythonic when calling
    repr(...) or str(...) on them. (LP: #1279977)

  [ Nicholas Skaggs ]
  * Fix the veribage for statenotfound errors, fixes
    https://bugs.launchpad.net/autopilot/+bug/1269649 (LP: #1269649)

  [ nskaggs ]
  * Fix the veribage for statenotfound errors, fixes
    https://bugs.launchpad.net/autopilot/+bug/1269649 (LP: #1269649)

  [ Christopher Lee ]
  * Prepare functional tests so that they can run on a device (Skips any
    that cannot run on a device).
 -- Ubuntu daily release <email address hidden> Mon, 03 Mar 2014 04:38:08 +0000

Changed in autopilot (Ubuntu):
status: New → Fix Released
Changed in autopilot:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.