Boolean properties reported as 0/1 but pretty-printed True/False in get_properties
Bug #1279977 reported by
Allan LeSage
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
lp:~thomir-deactivatedaccount/autopilot/trunk-fix-plain-type-reprs
- PS Jenkins bot: Needs Fixing (continuous-integration)
- Christopher Lee (community): Approve
-
Diff: 531 lines (+331/-61)2 files modifiedautopilot/introspection/types.py (+115/-60)
autopilot/tests/unit/test_types.py (+216/-1)
Changed in autopilot: | |
status: | New → In Progress |
assignee: | nobody → Thomi Richards (thomir) |
Changed in autopilot: | |
status: | In Progress → Fix Released |
To post a comment you must log in.
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:
--- True)'
In [7]: repr(b1)
Out[7]: 'dbus.Boolean(
In [8]: str(b1)
Out[8]: '1'
---
Cheers,