From 418143f9df40a051020a362176f4bd2e0066534f Mon Sep 17 00:00:00 2001 From: "giacomo.tanganelli@for.unipi.it" Date: Mon, 29 Jan 2018 14:56:12 +0100 Subject: [PATCH] Fix message.payload_type --- coapthon/serializer.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/coapthon/serializer.py b/coapthon/serializer.py index 68c7f00..c85445d 100644 --- a/coapthon/serializer.py +++ b/coapthon/serializer.py @@ -113,9 +113,12 @@ class Serializer(object): raise AttributeError("Packet length %s, pos %s" % (length_packet, pos)) message.payload = "" payload = values[pos:] - if message.payload_type == defines.Content_types["application/octet-stream"]: - message.payload = payload - else: + try: + if message.payload_type == defines.Content_types["application/octet-stream"]: + message.payload = payload + else: + message.payload = payload.decode("utf-8") + except AttributeError: message.payload = payload.decode("utf-8") pos += len(payload)