Re: Subclass Gio.DBusProxy and UnicodeDecodeError under python 3



On Sun, Dec 11, 2016 at 6:12 PM, infirit <infirit gmail com> wrote:
Hi all,

I subclassed Gio.DBusProxy and overridden the do_g_properties_changed
virtual function. In there I emit my own signal that consumers of the
proxy can connect to. I have created a minimal example of what I am
doing which you can find on [1].

The code from [1] runs perfectly fine under python2.7 with no
UnicodeDecodeError at any point, the situation under Python 3.4 however
is different. See below an example error. I narrowed it down to
overriding do_g_properties_changed, without that the error goes away.

  *connected function* /org/bluez/hci0/dev_7C_2F_80_3B_AF_AB RSSI -64
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position
0: invalid start byte

The strange thing is that it does not generate a traceback so I am not
entirely sure how to proceed with this. It also does not seem to result
in issues however my gut tells me not to ignore it. Anyone know what is
going on with this?

Under Python 2 text gets passed to Python as is (utf-8 encoded) while
under Python 3 things get decoded to unicode code points. I suspect
there is some invalid utf-8 involved which you should see in data
getting passed to do_g_properties_changed under py2.

I've tested your code (with adjusting the device path) and it seems to
work fine under py3 here.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]