{"action":"created","issue":{"url":"https://api.github.com/repos/ibnishak/Timimi/issues/6","repository_url":"https://api.github.com/repos/ibnishak/Timimi","labels_url":"https://api.github.com/repos/ibnishak/Timimi/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/ibnishak/Timimi/issues/6/comments","events_url":"https://api.github.com/repos/ibnishak/Timimi/issues/6/events","html_url":"https://github.com/ibnishak/Timimi/issues/6","id":391422436,"node_id":"MDU6SXNzdWUzOTE0MjI0MzY=","number":6,"title":"Saving fails on Python 2.x","user":{"login":"rmunn","id":90762,"node_id":"MDQ6VXNlcjkwNzYy","avatar_url":"https://avatars2.githubusercontent.com/u/90762?v=4","gravatar_id":"","url":"https://api.github.com/users/rmunn","html_url":"https://github.com/rmunn","followers_url":"https://api.github.com/users/rmunn/followers","following_url":"https://api.github.com/users/rmunn/following{/other_user}","gists_url":"https://api.github.com/users/rmunn/gists{/gist_id}","starred_url":"https://api.github.com/users/rmunn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmunn/subscriptions","organizations_url":"https://api.github.com/users/rmunn/orgs","repos_url":"https://api.github.com/users/rmunn/repos","events_url":"https://api.github.com/users/rmunn/events{/privacy}","received_events_url":"https://api.github.com/users/rmunn/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-12-16T00:05:56Z","updated_at":"2018-12-17T19:16:03Z","closed_at":"2018-12-17T19:14:56Z","author_association":"CONTRIBUTOR","body":"I believe I've figured out the reason behind #4. The `while True` loop for Python 2.x has the following code:\r\n\r\n```python\r\n        file=open(receivedMessage[\"path\"],\"w\", encoding='utf-8')\r\n        file.write(\"%s\" % (receivedMessage[\"content\"]))\r\n        file.close()\r\n```\r\n\r\nBut running `file = open(\"/tmp/example.json\", \"w\", encoding='utf-8')` in Python 2 gives the error `TypeError: 'encoding' is an invalid keyword argument for this function`.\r\n\r\nAccording to https://stackoverflow.com/questions/10971033/backporting-python-3-openencoding-utf-8-to-python-2, the simplest solution is to (in the Python 2 block) do `import io`, then use `io.open` instead of plain `open`. Then you just need to make sure that `receivedMessage[\"content\"]` is a Unicode object rather than a string (simplest way is to do `file.write(unicode(receivedMessage[\"content\"]))`) and the rest should work. (Tested locally on Mint 18 / Ubuntu 16.04 with Python 2.7)."},"comment":{"url":"https://api.github.com/repos/ibnishak/Timimi/issues/comments/447964341","html_url":"https://github.com/ibnishak/Timimi/issues/6#issuecomment-447964341","issue_url":"https://api.github.com/repos/ibnishak/Timimi/issues/6","id":447964341,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0Nzk2NDM0MQ==","user":{"login":"ibnishak","id":15052221,"node_id":"MDQ6VXNlcjE1MDUyMjIx","avatar_url":"https://avatars1.githubusercontent.com/u/15052221?v=4","gravatar_id":"","url":"https://api.github.com/users/ibnishak","html_url":"https://github.com/ibnishak","followers_url":"https://api.github.com/users/ibnishak/followers","following_url":"https://api.github.com/users/ibnishak/following{/other_user}","gists_url":"https://api.github.com/users/ibnishak/gists{/gist_id}","starred_url":"https://api.github.com/users/ibnishak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibnishak/subscriptions","organizations_url":"https://api.github.com/users/ibnishak/orgs","repos_url":"https://api.github.com/users/ibnishak/repos","events_url":"https://api.github.com/users/ibnishak/events{/privacy}","received_events_url":"https://api.github.com/users/ibnishak/received_events","type":"User","site_admin":false},"created_at":"2018-12-17T19:16:03Z","updated_at":"2018-12-17T19:16:03Z","author_association":"OWNER","body":"PR Merged"}}
{"actor":{"display_login":"ibnishak"}}