{"action":"created","issue":{"url":"https://api.github.com/repos/hexchat/hexchat/issues/869","labels_url":"https://api.github.com/repos/hexchat/hexchat/issues/869/labels{/name}","comments_url":"https://api.github.com/repos/hexchat/hexchat/issues/869/comments","events_url":"https://api.github.com/repos/hexchat/hexchat/issues/869/events","html_url":"https://github.com/hexchat/hexchat/issues/869","id":24870936,"number":869,"title":"[Python 3] HexChat passing non Unicode strings to Python 3","user":{"login":"Motoko11","id":6283378,"avatar_url":"https://avatars.githubusercontent.com/u/6283378?v=3","gravatar_id":"","url":"https://api.github.com/users/Motoko11","html_url":"https://github.com/Motoko11","followers_url":"https://api.github.com/users/Motoko11/followers","following_url":"https://api.github.com/users/Motoko11/following{/other_user}","gists_url":"https://api.github.com/users/Motoko11/gists{/gist_id}","starred_url":"https://api.github.com/users/Motoko11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Motoko11/subscriptions","organizations_url":"https://api.github.com/users/Motoko11/orgs","repos_url":"https://api.github.com/users/Motoko11/repos","events_url":"https://api.github.com/users/Motoko11/events{/privacy}","received_events_url":"https://api.github.com/users/Motoko11/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hexchat/hexchat/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/hexchat/hexchat/labels/plugin","name":"plugin","color":"5319e7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2013-12-30T01:17:03Z","updated_at":"2015-06-14T23:21:52Z","closed_at":"2015-02-02T08:01:18Z","body":"I've run into a problem where HexChat will pass non Unicode encoded strings into python when using the hexchat.hook_print(\"Key Press\") function. This raises the unicode error,  `\"UnicodeDecodeError: 'utf-8' codec can't decode byte 0x## in position 0: invalid start byte\"`. Due to Python 3 expecting all strings to be Unicode, there is no real way to fix this in the code itself as trying to access the variable containing the invalid string (In this case 'word') results in that exception. So far I've seen this exception work when you press the €, ¬, ¦ or £ keys. Also all accented characters are affected also. I expect it to be the same for any ANSI characters above 127. The following code will show you the error if you run it on Python 3.\r\n\r\n```py\r\nimport hexchat\r\n\r\n__module_name__ = \"Unicode Error\"\r\n__module_version__ = \"1.0\"\r\n__module_description__ = \"Will cause unicode error if ANSI > 127 character is pressed.\"\r\n\r\ndef crash_cb(word, word_eol, userdata):\r\n\tprint(word)\r\n\treturn hexchat.EAT_NONE\r\n\r\nhexchat.hook_print(\"Key Press\", crash_cb, priority=hexchat.PRI_HIGHEST)\r\n```\r\n\r\nAlso, I am using HexChat 2.9.6, and Python 3.3\r\n\r\nEdit: Confirmed by a friend, the same error is achieved with the keys å, ä, ö and µ.\r\n\r\n<bountysource-plugin>\r\n\r\n---\r\nWant to back this issue? **[Place a bounty on it!](https://www.bountysource.com/issues/1365811-python-3-hexchat-passing-non-unicode-strings-to-python-3?utm_campaign=plugin&utm_content=tracker%2F94103&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F94103&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/hexchat/hexchat/issues/comments/111884144","html_url":"https://github.com/hexchat/hexchat/issues/869#issuecomment-111884144","issue_url":"https://api.github.com/repos/hexchat/hexchat/issues/869","id":111884144,"user":{"login":"FichteFoll","id":931051,"avatar_url":"https://avatars.githubusercontent.com/u/931051?v=3","gravatar_id":"","url":"https://api.github.com/users/FichteFoll","html_url":"https://github.com/FichteFoll","followers_url":"https://api.github.com/users/FichteFoll/followers","following_url":"https://api.github.com/users/FichteFoll/following{/other_user}","gists_url":"https://api.github.com/users/FichteFoll/gists{/gist_id}","starred_url":"https://api.github.com/users/FichteFoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FichteFoll/subscriptions","organizations_url":"https://api.github.com/users/FichteFoll/orgs","repos_url":"https://api.github.com/users/FichteFoll/repos","events_url":"https://api.github.com/users/FichteFoll/events{/privacy}","received_events_url":"https://api.github.com/users/FichteFoll/received_events","type":"User","site_admin":false},"created_at":"2015-06-14T23:21:52Z","updated_at":"2015-06-14T23:21:52Z","body":"@tomek that works, thanks"}}