Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeErrors since a9357f30fded4f5934d99e07e23f19d74da18952 #620

Closed
infirit opened this issue Nov 26, 2016 · 7 comments
Closed

UnicodeDecodeErrors since a9357f30fded4f5934d99e07e23f19d74da18952 #620

infirit opened this issue Nov 26, 2016 · 7 comments
Assignees
Labels
Milestone

Comments

@infirit
Copy link
Contributor

infirit commented Nov 26, 2016

I have not run python 3 for a while (to make sure we do not break 2.7) but a9357f3 introduced UnicodeDecodeError under python 3 but it is not immediately obvious why. They show up for me when searching for devices just when discovery is stopped. Relevant bits from the logs below.
blueman-applet:

on_adapter_property_changed (/usr/lib64/python3.5/site-packages/blueman/plugins/applet/DiscvManager.py:89)
prop Discovering True 
_________
do_g_properties_changed (/usr/lib64/python3.5/site-packages/blueman/bluez/Base.py:81)
/org/bluez/hci0 Discovering True 
_________
do_g_properties_changed (/usr/lib64/python3.5/site-packages/blueman/bluez/Base.py:81)
/org/bluez/hci0/dev_7C_2F_80_3B_AF_AB RSSI -79 
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 1: invalid start byte
_________
on_adapter_property_changed (/usr/lib64/python3.5/site-packages/blueman/plugins/applet/DiscvManager.py:89)
prop Discovering False 

blueman-manager:

_________
do_g_properties_changed (/usr/lib64/python3.5/site-packages/blueman/bluez/Base.py:81)
/org/bluez/hci0 Discovering True 
_________
do_g_properties_changed (/usr/lib64/python3.5/site-packages/blueman/bluez/Base.py:81)
/org/bluez/hci0/dev_20_D4_E4_F6_C1_D6 RSSI -77 
_________
row_update_event (/usr/lib64/python3.5/site-packages/blueman/gui/manager/ManagerDeviceList.py:269)
row update event RSSI -77 
opacity 159
_________
do_g_properties_changed (/usr/lib64/python3.5/site-packages/blueman/bluez/Base.py:81)
/org/bluez/hci0/dev_D0_03_4B_E2_83_97 RSSI -78 
_________
row_update_event (/usr/lib64/python3.5/site-packages/blueman/gui/manager/ManagerDeviceList.py:269)
row update event RSSI -78 
opacity 156
_________
do_g_properties_changed (/usr/lib64/python3.5/site-packages/blueman/bluez/Base.py:81)
/org/bluez/hci0/dev_7C_2F_80_3B_AF_AB RSSI -79 
_________
row_update_event (/usr/lib64/python3.5/site-packages/blueman/gui/manager/ManagerDeviceList.py:269)
row update event RSSI -79 
opacity 153
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 0: invalid start byte
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 0: invalid start byte
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 0: invalid start byte
_________
do_g_properties_changed (/usr/lib64/python3.5/site-packages/blueman/bluez/Base.py:81)
/org/bluez/hci0 Discovering False 
@infirit infirit added the bug label Nov 26, 2016
@infirit infirit added this to the 2.1 milestone Nov 26, 2016
@infirit infirit self-assigned this Nov 26, 2016
@infirit
Copy link
Contributor Author

infirit commented Nov 28, 2016

From my testing it seems that it always happens after RSSI changes. The annoying thing is I get no traceback so it is difficult to find it 😢

@infirit
Copy link
Contributor Author

infirit commented Dec 10, 2016

I see RSSI set to nil in bluetoothctl and the number of lines with nill corresponds with the number of errors. It also makes sense it happens after discovery as RSSI is only available during discovery phase and at the end they get "nilled".

Excluding RSSI from do_gproperties_changed does not make a difference though.. so I am leaning towards this being an issue in pygi.

@infirit
Copy link
Contributor Author

infirit commented Dec 11, 2016

Easily reproducable with below. I am now confident that it is not something we are doing wrong. But I am not sure how to proceed now, should we just ignore (it does not cause us issues afaics) or report it to the pygi folks?

from gi.repository import Gio, GLib, GObject

class MyProxy(Gio.DBusProxy):
    __gsignals__ = {str('property-changed'): (GObject.SignalFlags.NO_HOOKS, None,
                     (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT))
    }

    def __init__(self, interface_name, obj_path, *args, **kwargs):
        super(MyProxy, self).__init__(
            g_name="org.bluez",
            g_interface_name=interface_name,
            g_object_path=obj_path,
            g_bus_type=Gio.BusType.SYSTEM,
            g_flags=Gio.DBusProxyFlags.NONE,
            *args, **kwargs)

        self.init()

    def do_g_properties_changed(self, changed_properties, _invalidated_properties):
        for key, value in changed_properties.unpack().items():
            path = self.get_object_path()
            print("*%s*" % self.__class__, path, key, value)
            self.emit("property-changed", key, value, path)

def print_changed_property(proxy, key, value, path):
    print("*connected function*", path, key, value)

proxy = MyProxy("org.bluez.Device1", "/org/bluez/hci0/dev_7C_2F_80_3B_AF_AB")
proxy.connect("property-changed", print_changed_property)

loop = GLib.MainLoop()
loop.run()

@infirit
Copy link
Contributor Author

infirit commented Dec 13, 2016

AFAICS the problem is in the virtual function, specifically the invalidated properties. I can work around it by use GET_INVALIDATED_PROPERTIES flags instead of NONE.

For reference:
https://mail.gnome.org/archives/python-hackers-list/2016-December/msg00003.html
#628

@infirit
Copy link
Contributor Author

infirit commented Dec 27, 2016

Found a bug open on it https://bugzilla.gnome.org/show_bug.cgi?id=756009

@cschramm
Copy link
Member

cschramm commented Jan 3, 2017

So I guess we can close this as it's not our fault and we have a workaround.

@infirit
Copy link
Contributor Author

infirit commented Jan 3, 2017

Yup, closing now that I merged the workaround,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants