{"action":"created","issue":{"url":"https://api.github.com/repos/pebble/libpebble2/issues/13","labels_url":"https://api.github.com/repos/pebble/libpebble2/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/pebble/libpebble2/issues/13/comments","events_url":"https://api.github.com/repos/pebble/libpebble2/issues/13/events","html_url":"https://github.com/pebble/libpebble2/issues/13","id":114786732,"number":13,"title":"\"TypeError: Type str doesn't support the buffer API\" when receiving CString appmessage from Pebble","user":{"login":"Owantjaaaa","id":8659263,"avatar_url":"https://avatars.githubusercontent.com/u/8659263?v=3","gravatar_id":"","url":"https://api.github.com/users/Owantjaaaa","html_url":"https://github.com/Owantjaaaa","followers_url":"https://api.github.com/users/Owantjaaaa/followers","following_url":"https://api.github.com/users/Owantjaaaa/following{/other_user}","gists_url":"https://api.github.com/users/Owantjaaaa/gists{/gist_id}","starred_url":"https://api.github.com/users/Owantjaaaa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Owantjaaaa/subscriptions","organizations_url":"https://api.github.com/users/Owantjaaaa/orgs","repos_url":"https://api.github.com/users/Owantjaaaa/repos","events_url":"https://api.github.com/users/Owantjaaaa/events{/privacy}","received_events_url":"https://api.github.com/users/Owantjaaaa/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-03T10:40:34Z","updated_at":"2015-11-03T19:57:17Z","closed_at":"2015-11-03T19:55:46Z","body":"After sending a CString using dict_write_cstring the following error occurs\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.2/threading.py\", line 740, in _bootstrap_inner\r\n    self.run()\r\n  File \"/usr/lib/python3.2/threading.py\", line 693, in run\r\n    self._target(*self._args, **self._kwargs)\r\n  File \"/usr/local/lib/python3.2/dist-packages/libpebble2/communication/__init__   .py\", line 88, in run_sync\r\n    self.pump_reader()\r\n  File \"/usr/local/lib/python3.2/dist-packages/libpebble2/communication/__init__   .py\", line 75, in pump_reader\r\n    self._handle_watch_message(message)\r\n  File \"/usr/local/lib/python3.2/dist-packages/libpebble2/communication/__init__   .py\", line 139, in _handle_watch_message\r\n    self.event_handler.broadcast_event((_EventType.Watch, type(packet)), packet)\r\n  File \"/usr/local/lib/python3.2/dist-packages/libpebble2/events/threaded.py\", l   ine 44, in broadcast_event\r\n    handler(*args)\r\n  File \"/usr/local/lib/python3.2/dist-packages/libpebble2/services/appmessage.py   \", line 58, in _handle_message\r\n    result[t.key] = t.data.split('\\x00')[0]\r\nTypeError: Type str doesn't support the buffer API\r\n```\r\n\r\nchanging\r\n\r\n    elif t.type == AppMessageTuple.Type.CString:\r\n        result[t.key] = t.data.split('\\x00')[0]\r\n\r\nto \r\n\r\n    elif t.type == AppMessageTuple.Type.CString:\r\n        result[t.key] = t.data.decode(\"utf-8\")\r\n\r\nseems to fix this issue"},"comment":{"url":"https://api.github.com/repos/pebble/libpebble2/issues/comments/153469980","html_url":"https://github.com/pebble/libpebble2/issues/13#issuecomment-153469980","issue_url":"https://api.github.com/repos/pebble/libpebble2/issues/13","id":153469980,"user":{"login":"Katharine","id":110792,"avatar_url":"https://avatars.githubusercontent.com/u/110792?v=3","gravatar_id":"","url":"https://api.github.com/users/Katharine","html_url":"https://github.com/Katharine","followers_url":"https://api.github.com/users/Katharine/followers","following_url":"https://api.github.com/users/Katharine/following{/other_user}","gists_url":"https://api.github.com/users/Katharine/gists{/gist_id}","starred_url":"https://api.github.com/users/Katharine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Katharine/subscriptions","organizations_url":"https://api.github.com/users/Katharine/orgs","repos_url":"https://api.github.com/users/Katharine/repos","events_url":"https://api.github.com/users/Katharine/events{/privacy}","received_events_url":"https://api.github.com/users/Katharine/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T19:57:17Z","updated_at":"2015-11-03T19:57:17Z","body":"Sorry! I added a test around this so it shouldn't happen again.\r\n\r\nEnded up with this:\r\n\r\n```python\r\nresult[t.key] = t.data.split(b'\\x00')[0].decode('utf-8', errors='replace')\r\n```"}}