{"action":"created","comment":{"url":"https://api.github.com/repos/zulip/zulip/pulls/comments/157919728","pull_request_review_id":84642386,"id":157919728,"diff_hunk":"@@ -356,7 +356,7 @@ def ensure_medium_avatar_image(self, user_profile: UserProfile) -> None:\n         conn = S3Connection(settings.S3_KEY, settings.S3_SECRET_KEY)\n         bucket = get_bucket(conn, bucket_name)\n         key = bucket.get_key(file_path)\n-        image_data = force_bytes(key.get_contents_as_string())\n+        image_data = key.get_contents_as_string().encode('utf8')","path":"zerver/lib/upload.py","position":14,"original_position":14,"commit_id":"64fe9d82c62a18179389eb109814c1803b2ff55e","original_commit_id":"64fe9d82c62a18179389eb109814c1803b2ff55e","user":{"login":"gnprice","id":28173,"avatar_url":"https://avatars1.githubusercontent.com/u/28173?v=4","gravatar_id":"","url":"https://api.github.com/users/gnprice","html_url":"https://github.com/gnprice","followers_url":"https://api.github.com/users/gnprice/followers","following_url":"https://api.github.com/users/gnprice/following{/other_user}","gists_url":"https://api.github.com/users/gnprice/gists{/gist_id}","starred_url":"https://api.github.com/users/gnprice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnprice/subscriptions","organizations_url":"https://api.github.com/users/gnprice/orgs","repos_url":"https://api.github.com/users/gnprice/repos","events_url":"https://api.github.com/users/gnprice/events{/privacy}","received_events_url":"https://api.github.com/users/gnprice/received_events","type":"User","site_admin":false},"body":"Hmm. I'd think that an image's binary data would often simply not be valid UTF-8 -- it's not meant to be text, or to be decoded as UTF-8. What type does this `get_contents_as_string` return -- is it in fact a string, or is the name wrong and it's a bytestring? If it's a string, I'm confused how the code could be working even now.\r\n\r\nIf it is a string, is there a parallel method like `get_contents_as_bytes` or `get_contents` that we could use to get bytes?\r\n","created_at":"2017-12-20T01:35:08Z","updated_at":"2017-12-20T01:39:50Z","html_url":"https://github.com/zulip/zulip/pull/7822#discussion_r157919728","pull_request_url":"https://api.github.com/repos/zulip/zulip/pulls/7822","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/zulip/zulip/pulls/comments/157919728"},"html":{"href":"https://github.com/zulip/zulip/pull/7822#discussion_r157919728"},"pull_request":{"href":"https://api.github.com/repos/zulip/zulip/pulls/7822"}}},"pull_request":{"url":"https://api.github.com/repos/zulip/zulip/pulls/7822","id":158922957,"html_url":"https://github.com/zulip/zulip/pull/7822","diff_url":"https://github.com/zulip/zulip/pull/7822.diff","patch_url":"https://github.com/zulip/zulip/pull/7822.patch","issue_url":"https://api.github.com/repos/zulip/zulip/issues/7822","number":7822,"state":"open","locked":false,"title":"[WIP] Sweep force_bytes/force_str/force_text and replace with encode/decode.","user":{"login":"rheaparekh","id":25330892,"avatar_url":"https://avatars0.githubusercontent.com/u/25330892?v=4","gravatar_id":"","url":"https://api.github.com/users/rheaparekh","html_url":"https://github.com/rheaparekh","followers_url":"https://api.github.com/users/rheaparekh/followers","following_url":"https://api.github.com/users/rheaparekh/following{/other_user}","gists_url":"https://api.github.com/users/rheaparekh/gists{/gist_id}","starred_url":"https://api.github.com/users/rheaparekh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rheaparekh/subscriptions","organizations_url":"https://api.github.com/users/rheaparekh/orgs","repos_url":"https://api.github.com/users/rheaparekh/repos","events_url":"https://api.github.com/users/rheaparekh/events{/privacy}","received_events_url":"https://api.github.com/users/rheaparekh/received_events","type":"User","site_admin":false},"body":"Fix for issue  #7240","created_at":"2017-12-18T14:10:36Z","updated_at":"2017-12-20T01:39:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"72dcdc47f6acbb2061d21fef953f21d5b3587912","assignee":{"login":"gnprice","id":28173,"avatar_url":"https://avatars1.githubusercontent.com/u/28173?v=4","gravatar_id":"","url":"https://api.github.com/users/gnprice","html_url":"https://github.com/gnprice","followers_url":"https://api.github.com/users/gnprice/followers","following_url":"https://api.github.com/users/gnprice/following{/other_user}","gists_url":"https://api.github.com/users/gnprice/gists{/gist_id}","starred_url":"https://api.github.com/users/gnprice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnprice/subscriptions","organizations_url":"https://api.github.com/users/gnprice/orgs","repos_url":"https://api.github.com/users/gnprice/repos","events_url":"https://api.github.com/users/gnprice/events{/privacy}","received_events_url":"https://api.github.com/users/gnprice/received_events","type":"User","site_admin":false},"assignees":[{"login":"gnprice","id":28173,"avatar_url":"https://avatars1.githubusercontent.com/u/28173?v=4","gravatar_id":"","url":"https://api.github.com/users/gnprice","html_url":"https://github.com/gnprice","followers_url":"https://api.github.com/users/gnprice/followers","following_url":"https://api.github.com/users/gnprice/following{/other_user}","gists_url":"https://api.github.com/users/gnprice/gists{/gist_id}","starred_url":"https://api.github.com/users/gnprice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnprice/subscriptions","organizations_url":"https://api.github.com/users/gnprice/orgs","repos_url":"https://api.github.com/users/gnprice/repos","events_url":"https://api.github.com/users/gnprice/events{/privacy}","received_events_url":"https://api.github.com/users/gnprice/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/zulip/zulip/pulls/7822/commits","review_comments_url":"https://api.github.com/repos/zulip/zulip/pulls/7822/comments","review_comment_url":"https://api.github.com/repos/zulip/zulip/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zulip/zulip/issues/7822/comments","statuses_url":"https://api.github.com/repos/zulip/zulip/statuses/64fe9d82c62a18179389eb109814c1803b2ff55e","head":{"label":"rheaparekh:issue-7240","ref":"issue-7240","sha":"64fe9d82c62a18179389eb109814c1803b2ff55e","user":{"login":"rheaparekh","id":25330892,"avatar_url":"https://avatars0.githubusercontent.com/u/25330892?v=4","gravatar_id":"","url":"https://api.github.com/users/rheaparekh","html_url":"https://github.com/rheaparekh","followers_url":"https://api.github.com/users/rheaparekh/followers","following_url":"https://api.github.com/users/rheaparekh/following{/other_user}","gists_url":"https://api.github.com/users/rheaparekh/gists{/gist_id}","starred_url":"https://api.github.com/users/rheaparekh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rheaparekh/subscriptions","organizations_url":"https://api.github.com/users/rheaparekh/orgs","repos_url":"https://api.github.com/users/rheaparekh/repos","events_url":"https://api.github.com/users/rheaparekh/events{/privacy}","received_events_url":"https://api.github.com/users/rheaparekh/received_events","type":"User","site_admin":false},"repo":{"id":103392316,"name":"zulip","full_name":"rheaparekh/zulip","owner":{"login":"rheaparekh","id":25330892,"avatar_url":"https://avatars0.githubusercontent.com/u/25330892?v=4","gravatar_id":"","url":"https://api.github.com/users/rheaparekh","html_url":"https://github.com/rheaparekh","followers_url":"https://api.github.com/users/rheaparekh/followers","following_url":"https://api.github.com/users/rheaparekh/following{/other_user}","gists_url":"https://api.github.com/users/rheaparekh/gists{/gist_id}","starred_url":"https://api.github.com/users/rheaparekh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rheaparekh/subscriptions","organizations_url":"https://api.github.com/users/rheaparekh/orgs","repos_url":"https://api.github.com/users/rheaparekh/repos","events_url":"https://api.github.com/users/rheaparekh/events{/privacy}","received_events_url":"https://api.github.com/users/rheaparekh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rheaparekh/zulip","description":"Zulip server - powerful open source group chat","fork":true,"url":"https://api.github.com/repos/rheaparekh/zulip","forks_url":"https://api.github.com/repos/rheaparekh/zulip/forks","keys_url":"https://api.github.com/repos/rheaparekh/zulip/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rheaparekh/zulip/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rheaparekh/zulip/teams","hooks_url":"https://api.github.com/repos/rheaparekh/zulip/hooks","issue_events_url":"https://api.github.com/repos/rheaparekh/zulip/issues/events{/number}","events_url":"https://api.github.com/repos/rheaparekh/zulip/events","assignees_url":"https://api.github.com/repos/rheaparekh/zulip/assignees{/user}","branches_url":"https://api.github.com/repos/rheaparekh/zulip/branches{/branch}","tags_url":"https://api.github.com/repos/rheaparekh/zulip/tags","blobs_url":"https://api.github.com/repos/rheaparekh/zulip/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rheaparekh/zulip/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rheaparekh/zulip/git/refs{/sha}","trees_url":"https://api.github.com/repos/rheaparekh/zulip/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rheaparekh/zulip/statuses/{sha}","languages_url":"https://api.github.com/repos/rheaparekh/zulip/languages","stargazers_url":"https://api.github.com/repos/rheaparekh/zulip/stargazers","contributors_url":"https://api.github.com/repos/rheaparekh/zulip/contributors","subscribers_url":"https://api.github.com/repos/rheaparekh/zulip/subscribers","subscription_url":"https://api.github.com/repos/rheaparekh/zulip/subscription","commits_url":"https://api.github.com/repos/rheaparekh/zulip/commits{/sha}","git_commits_url":"https://api.github.com/repos/rheaparekh/zulip/git/commits{/sha}","comments_url":"https://api.github.com/repos/rheaparekh/zulip/comments{/number}","issue_comment_url":"https://api.github.com/repos/rheaparekh/zulip/issues/comments{/number}","contents_url":"https://api.github.com/repos/rheaparekh/zulip/contents/{+path}","compare_url":"https://api.github.com/repos/rheaparekh/zulip/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rheaparekh/zulip/merges","archive_url":"https://api.github.com/repos/rheaparekh/zulip/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rheaparekh/zulip/downloads","issues_url":"https://api.github.com/repos/rheaparekh/zulip/issues{/number}","pulls_url":"https://api.github.com/repos/rheaparekh/zulip/pulls{/number}","milestones_url":"https://api.github.com/repos/rheaparekh/zulip/milestones{/number}","notifications_url":"https://api.github.com/repos/rheaparekh/zulip/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rheaparekh/zulip/labels{/name}","releases_url":"https://api.github.com/repos/rheaparekh/zulip/releases{/id}","deployments_url":"https://api.github.com/repos/rheaparekh/zulip/deployments","created_at":"2017-09-13T11:38:08Z","updated_at":"2017-09-13T11:38:18Z","pushed_at":"2017-12-18T13:22:31Z","git_url":"git://github.com/rheaparekh/zulip.git","ssh_url":"git@github.com:rheaparekh/zulip.git","clone_url":"https://github.com/rheaparekh/zulip.git","svn_url":"https://github.com/rheaparekh/zulip","homepage":"","size":189496,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"zulip:master","ref":"master","sha":"2fc0272a5d40b9651cb2e55939a43509b90f6e9b","user":{"login":"zulip","id":4921959,"avatar_url":"https://avatars2.githubusercontent.com/u/4921959?v=4","gravatar_id":"","url":"https://api.github.com/users/zulip","html_url":"https://github.com/zulip","followers_url":"https://api.github.com/users/zulip/followers","following_url":"https://api.github.com/users/zulip/following{/other_user}","gists_url":"https://api.github.com/users/zulip/gists{/gist_id}","starred_url":"https://api.github.com/users/zulip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zulip/subscriptions","organizations_url":"https://api.github.com/users/zulip/orgs","repos_url":"https://api.github.com/users/zulip/repos","events_url":"https://api.github.com/users/zulip/events{/privacy}","received_events_url":"https://api.github.com/users/zulip/received_events","type":"Organization","site_admin":false},"repo":{"id":43160685,"name":"zulip","full_name":"zulip/zulip","owner":{"login":"zulip","id":4921959,"avatar_url":"https://avatars2.githubusercontent.com/u/4921959?v=4","gravatar_id":"","url":"https://api.github.com/users/zulip","html_url":"https://github.com/zulip","followers_url":"https://api.github.com/users/zulip/followers","following_url":"https://api.github.com/users/zulip/following{/other_user}","gists_url":"https://api.github.com/users/zulip/gists{/gist_id}","starred_url":"https://api.github.com/users/zulip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zulip/subscriptions","organizations_url":"https://api.github.com/users/zulip/orgs","repos_url":"https://api.github.com/users/zulip/repos","events_url":"https://api.github.com/users/zulip/events{/privacy}","received_events_url":"https://api.github.com/users/zulip/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zulip/zulip","description":"Zulip server - powerful open source team chat","fork":false,"url":"https://api.github.com/repos/zulip/zulip","forks_url":"https://api.github.com/repos/zulip/zulip/forks","keys_url":"https://api.github.com/repos/zulip/zulip/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zulip/zulip/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zulip/zulip/teams","hooks_url":"https://api.github.com/repos/zulip/zulip/hooks","issue_events_url":"https://api.github.com/repos/zulip/zulip/issues/events{/number}","events_url":"https://api.github.com/repos/zulip/zulip/events","assignees_url":"https://api.github.com/repos/zulip/zulip/assignees{/user}","branches_url":"https://api.github.com/repos/zulip/zulip/branches{/branch}","tags_url":"https://api.github.com/repos/zulip/zulip/tags","blobs_url":"https://api.github.com/repos/zulip/zulip/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zulip/zulip/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zulip/zulip/git/refs{/sha}","trees_url":"https://api.github.com/repos/zulip/zulip/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zulip/zulip/statuses/{sha}","languages_url":"https://api.github.com/repos/zulip/zulip/languages","stargazers_url":"https://api.github.com/repos/zulip/zulip/stargazers","contributors_url":"https://api.github.com/repos/zulip/zulip/contributors","subscribers_url":"https://api.github.com/repos/zulip/zulip/subscribers","subscription_url":"https://api.github.com/repos/zulip/zulip/subscription","commits_url":"https://api.github.com/repos/zulip/zulip/commits{/sha}","git_commits_url":"https://api.github.com/repos/zulip/zulip/git/commits{/sha}","comments_url":"https://api.github.com/repos/zulip/zulip/comments{/number}","issue_comment_url":"https://api.github.com/repos/zulip/zulip/issues/comments{/number}","contents_url":"https://api.github.com/repos/zulip/zulip/contents/{+path}","compare_url":"https://api.github.com/repos/zulip/zulip/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zulip/zulip/merges","archive_url":"https://api.github.com/repos/zulip/zulip/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zulip/zulip/downloads","issues_url":"https://api.github.com/repos/zulip/zulip/issues{/number}","pulls_url":"https://api.github.com/repos/zulip/zulip/pulls{/number}","milestones_url":"https://api.github.com/repos/zulip/zulip/milestones{/number}","notifications_url":"https://api.github.com/repos/zulip/zulip/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zulip/zulip/labels{/name}","releases_url":"https://api.github.com/repos/zulip/zulip/releases{/id}","deployments_url":"https://api.github.com/repos/zulip/zulip/deployments","created_at":"2015-09-25T16:37:25Z","updated_at":"2017-12-20T01:20:46Z","pushed_at":"2017-12-20T01:13:17Z","git_url":"git://github.com/zulip/zulip.git","ssh_url":"git@github.com:zulip/zulip.git","clone_url":"https://github.com/zulip/zulip.git","svn_url":"https://github.com/zulip/zulip","homepage":"https://zulip.org/","size":189355,"stargazers_count":5686,"watchers_count":5686,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1833,"mirror_url":null,"archived":false,"open_issues_count":1036,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1833,"open_issues":1036,"watchers":5686,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zulip/zulip/pulls/7822"},"html":{"href":"https://github.com/zulip/zulip/pull/7822"},"issue":{"href":"https://api.github.com/repos/zulip/zulip/issues/7822"},"comments":{"href":"https://api.github.com/repos/zulip/zulip/issues/7822/comments"},"review_comments":{"href":"https://api.github.com/repos/zulip/zulip/pulls/7822/comments"},"review_comment":{"href":"https://api.github.com/repos/zulip/zulip/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zulip/zulip/pulls/7822/commits"},"statuses":{"href":"https://api.github.com/repos/zulip/zulip/statuses/64fe9d82c62a18179389eb109814c1803b2ff55e"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"gnprice"}}