From f811313ace319095b2cacdcb0894d137210a14ff Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 16 May 2015 18:20:40 +0200 Subject: fix poll MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/bus.py | 9 ++++++--- src/native_bus.pyx | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/bus.py b/src/bus.py index ddc0410..31908d0 100644 --- a/src/bus.py +++ b/src/bus.py @@ -208,7 +208,7 @@ class Bus: raise self.__oserror() - def poll(self) -> str: + def poll(self) -> bytes: ''' Wait for a message to be broadcasted on the bus. The caller should make a copy of the received message, @@ -217,11 +217,14 @@ class Bus: started, the caller of this function should then either call `Bus.poll` again or `Bus.poll_stop`. - @return :str The received message + @return :bytes The received message + NB! The received message will not be decoded from UTF-8 ''' from native_bus import bus_poll_wrapped - if bus_poll_wrapped(self.bus) == None: + message = bus_poll_wrapped(self.bus) + if message is None: raise self.__oserror() + return message def chown(self, owner : int, group : int): diff --git a/src/native_bus.pyx b/src/native_bus.pyx index c3c4039..75bb92a 100644 --- a/src/native_bus.pyx +++ b/src/native_bus.pyx @@ -332,7 +332,7 @@ def bus_poll_stop_wrapped(bus : int) -> int: return bus_poll_stop(bus) -def bus_poll_wrapped(bus : int) -> str: +def bus_poll_wrapped(bus : int) -> bytes: ''' Wait for a message to be broadcasted on the bus. The caller should make a copy of the received message, @@ -351,7 +351,7 @@ def bus_poll_wrapped(bus : int) -> str: if msg is NULL: return None bs = msg - return bs.decode('utf-8', 'strict') + return bs def bus_chown_wrapped(file : str, owner : int, group : int) -> int: -- cgit v1.2.3-70-g09d2