{"action":"created","comment":{"url":"https://api.github.com/repos/buildbot/buildbot/pulls/comments/34279653","id":34279653,"diff_hunk":"@@ -0,0 +1,74 @@\n+Python3 compatibility\n+=====================\n+\n+\n+A good place to start looking for advice to ensure that any code is compatible with both python-3.x and python2.7/2.6\n+is too look at the python-future `cheat sheet <http://python-future.org/compatible_idioms.html>`_ .\n+Buildbot uses the python-future library to ensure compatability with both python2.7/2.6 and python3.x.\n+\n+\n+Dictionaries\n+------------\n+In python3, ``dict.iteritems`` is no longer available. While ``dict.items()`` does exist, it can be memory\n+itensive in python2. For this reason, please use the python.future function ``iteritems()``\n+\n+Example::\n+\n+    d = {\"cheese\": 4, \"bread\": 5, \"milk\": 1}\n+    for item, num in d.iteritems():\n+        print(\"We have {} {}\".format(num, item))\n+\n+should be written as::\n+\n+    from future.utils import iteritems\n+    d = {\"cheese\": 4, \"bread\": 5, \"milk\": 1}\n+    for item, num in iteritems(d):\n+        print(\"We have {} {}\".format(num, item))\n+\n+This also applies to the similar methods ``dict.itervalues()`` and ``dict.values()``, which have an equivalent ``itervalues()``\n+\n+If a list is required, please use ``list(iteritems(dict))``. This is for compatibility with the six library\n+\n+For iterating over dictionary keys, please use ``for key in dict:``.\n+For example::\n+\n+    d = {\"cheese\": 4, \"bread\": 5, \"milk\": 1}\n+    for item in d:\n+        print(\"We have {}\".format(item))\n+\n+Similarly when you want a list of keys::\n+\n+    keys = list(d)\n+\n+Strings\n+-------\n+In python2, there is only one type of string. It can be both unicode and bytestring. In python3, this is\n+no longer the case. For this reasons all string must be marked with either ``u''`` or ``b''`` to signify if\n+the string is a unicode string or a bytestring respectively\n+\n+Example::\n+\n+    u'this is a unicode string, a string for humans to read'\n+    b'This is a bytestring, a string for computers to read'\n+\n+Print statements\n+----------------\n+Print statements are gone in python3. Please import ``from __future__ import print_function`` at the very top\n+of the module to enable use of python3 style print functions\n+\n+Exceptions\n+----------\n+All exceptions should be written with the ``as`` statement. Before::\n+\n+    try:\n+        number = 5/0\n+    except ZeroDivisionError, e:","path":"master/docs/developer/py3-compat.rst","position":65,"original_position":65,"commit_id":"7c726bb9ed846ab9a83abc1c8a2163f1183d40c0","original_commit_id":"7c726bb9ed846ab9a83abc1c8a2163f1183d40c0","user":{"login":"sa2ajj","id":447092,"avatar_url":"https://avatars.githubusercontent.com/u/447092?v=3","gravatar_id":"","url":"https://api.github.com/users/sa2ajj","html_url":"https://github.com/sa2ajj","followers_url":"https://api.github.com/users/sa2ajj/followers","following_url":"https://api.github.com/users/sa2ajj/following{/other_user}","gists_url":"https://api.github.com/users/sa2ajj/gists{/gist_id}","starred_url":"https://api.github.com/users/sa2ajj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sa2ajj/subscriptions","organizations_url":"https://api.github.com/users/sa2ajj/orgs","repos_url":"https://api.github.com/users/sa2ajj/repos","events_url":"https://api.github.com/users/sa2ajj/events{/privacy}","received_events_url":"https://api.github.com/users/sa2ajj/received_events","type":"User","site_admin":false},"body":"That's what I do not like about Python: there's PEP-8, but they themselves do not follow it in core library nor in the docs :/","created_at":"2015-07-09T17:23:43Z","updated_at":"2015-07-09T17:23:43Z","html_url":"https://github.com/buildbot/buildbot/pull/1764#discussion_r34279653","pull_request_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1764","_links":{"self":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/comments/34279653"},"html":{"href":"https://github.com/buildbot/buildbot/pull/1764#discussion_r34279653"},"pull_request":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1764"}}},"pull_request":{"url":"https://api.github.com/repos/buildbot/buildbot/pulls/1764","id":39602618,"html_url":"https://github.com/buildbot/buildbot/pull/1764","diff_url":"https://github.com/buildbot/buildbot/pull/1764.diff","patch_url":"https://github.com/buildbot/buildbot/pull/1764.patch","issue_url":"https://api.github.com/repos/buildbot/buildbot/issues/1764","number":1764,"state":"open","locked":false,"title":"[WIP] Add python3 compatability docs","user":{"login":"jvlomax","id":1144696,"avatar_url":"https://avatars.githubusercontent.com/u/1144696?v=3","gravatar_id":"","url":"https://api.github.com/users/jvlomax","html_url":"https://github.com/jvlomax","followers_url":"https://api.github.com/users/jvlomax/followers","following_url":"https://api.github.com/users/jvlomax/following{/other_user}","gists_url":"https://api.github.com/users/jvlomax/gists{/gist_id}","starred_url":"https://api.github.com/users/jvlomax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvlomax/subscriptions","organizations_url":"https://api.github.com/users/jvlomax/orgs","repos_url":"https://api.github.com/users/jvlomax/repos","events_url":"https://api.github.com/users/jvlomax/events{/privacy}","received_events_url":"https://api.github.com/users/jvlomax/received_events","type":"User","site_admin":false},"body":"This is an early version to cover the work done on buildbot so far. More will be added","created_at":"2015-07-09T16:31:28Z","updated_at":"2015-07-09T17:23:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"daf4df91e26f98a5b0817f614d126dcd5b7a9906","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1764/commits","review_comments_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1764/comments","review_comment_url":"https://api.github.com/repos/buildbot/buildbot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/buildbot/buildbot/issues/1764/comments","statuses_url":"https://api.github.com/repos/buildbot/buildbot/statuses/7c726bb9ed846ab9a83abc1c8a2163f1183d40c0","head":{"label":"jvlomax:documentation_update","ref":"documentation_update","sha":"7c726bb9ed846ab9a83abc1c8a2163f1183d40c0","user":{"login":"jvlomax","id":1144696,"avatar_url":"https://avatars.githubusercontent.com/u/1144696?v=3","gravatar_id":"","url":"https://api.github.com/users/jvlomax","html_url":"https://github.com/jvlomax","followers_url":"https://api.github.com/users/jvlomax/followers","following_url":"https://api.github.com/users/jvlomax/following{/other_user}","gists_url":"https://api.github.com/users/jvlomax/gists{/gist_id}","starred_url":"https://api.github.com/users/jvlomax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvlomax/subscriptions","organizations_url":"https://api.github.com/users/jvlomax/orgs","repos_url":"https://api.github.com/users/jvlomax/repos","events_url":"https://api.github.com/users/jvlomax/events{/privacy}","received_events_url":"https://api.github.com/users/jvlomax/received_events","type":"User","site_admin":false},"repo":{"id":32319801,"name":"buildbot","full_name":"jvlomax/buildbot","owner":{"login":"jvlomax","id":1144696,"avatar_url":"https://avatars.githubusercontent.com/u/1144696?v=3","gravatar_id":"","url":"https://api.github.com/users/jvlomax","html_url":"https://github.com/jvlomax","followers_url":"https://api.github.com/users/jvlomax/followers","following_url":"https://api.github.com/users/jvlomax/following{/other_user}","gists_url":"https://api.github.com/users/jvlomax/gists{/gist_id}","starred_url":"https://api.github.com/users/jvlomax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvlomax/subscriptions","organizations_url":"https://api.github.com/users/jvlomax/orgs","repos_url":"https://api.github.com/users/jvlomax/repos","events_url":"https://api.github.com/users/jvlomax/events{/privacy}","received_events_url":"https://api.github.com/users/jvlomax/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jvlomax/buildbot","description":"Python-based continuous integration testing framework; send pull requests for your patches!","fork":true,"url":"https://api.github.com/repos/jvlomax/buildbot","forks_url":"https://api.github.com/repos/jvlomax/buildbot/forks","keys_url":"https://api.github.com/repos/jvlomax/buildbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jvlomax/buildbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jvlomax/buildbot/teams","hooks_url":"https://api.github.com/repos/jvlomax/buildbot/hooks","issue_events_url":"https://api.github.com/repos/jvlomax/buildbot/issues/events{/number}","events_url":"https://api.github.com/repos/jvlomax/buildbot/events","assignees_url":"https://api.github.com/repos/jvlomax/buildbot/assignees{/user}","branches_url":"https://api.github.com/repos/jvlomax/buildbot/branches{/branch}","tags_url":"https://api.github.com/repos/jvlomax/buildbot/tags","blobs_url":"https://api.github.com/repos/jvlomax/buildbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jvlomax/buildbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jvlomax/buildbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/jvlomax/buildbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jvlomax/buildbot/statuses/{sha}","languages_url":"https://api.github.com/repos/jvlomax/buildbot/languages","stargazers_url":"https://api.github.com/repos/jvlomax/buildbot/stargazers","contributors_url":"https://api.github.com/repos/jvlomax/buildbot/contributors","subscribers_url":"https://api.github.com/repos/jvlomax/buildbot/subscribers","subscription_url":"https://api.github.com/repos/jvlomax/buildbot/subscription","commits_url":"https://api.github.com/repos/jvlomax/buildbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/jvlomax/buildbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/jvlomax/buildbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/jvlomax/buildbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/jvlomax/buildbot/contents/{+path}","compare_url":"https://api.github.com/repos/jvlomax/buildbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jvlomax/buildbot/merges","archive_url":"https://api.github.com/repos/jvlomax/buildbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jvlomax/buildbot/downloads","issues_url":"https://api.github.com/repos/jvlomax/buildbot/issues{/number}","pulls_url":"https://api.github.com/repos/jvlomax/buildbot/pulls{/number}","milestones_url":"https://api.github.com/repos/jvlomax/buildbot/milestones{/number}","notifications_url":"https://api.github.com/repos/jvlomax/buildbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jvlomax/buildbot/labels{/name}","releases_url":"https://api.github.com/repos/jvlomax/buildbot/releases{/id}","created_at":"2015-03-16T11:17:06Z","updated_at":"2015-03-19T20:27:57Z","pushed_at":"2015-07-09T16:30:44Z","git_url":"git://github.com/jvlomax/buildbot.git","ssh_url":"git@github.com:jvlomax/buildbot.git","clone_url":"https://github.com/jvlomax/buildbot.git","svn_url":"https://github.com/jvlomax/buildbot","homepage":"http://buildbot.net","size":36402,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"buildbot:master","ref":"master","sha":"7c943890801654da6cd89fd49e0816c72ce0f966","user":{"login":"buildbot","id":324515,"avatar_url":"https://avatars.githubusercontent.com/u/324515?v=3","gravatar_id":"","url":"https://api.github.com/users/buildbot","html_url":"https://github.com/buildbot","followers_url":"https://api.github.com/users/buildbot/followers","following_url":"https://api.github.com/users/buildbot/following{/other_user}","gists_url":"https://api.github.com/users/buildbot/gists{/gist_id}","starred_url":"https://api.github.com/users/buildbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buildbot/subscriptions","organizations_url":"https://api.github.com/users/buildbot/orgs","repos_url":"https://api.github.com/users/buildbot/repos","events_url":"https://api.github.com/users/buildbot/events{/privacy}","received_events_url":"https://api.github.com/users/buildbot/received_events","type":"Organization","site_admin":false},"repo":{"id":760165,"name":"buildbot","full_name":"buildbot/buildbot","owner":{"login":"buildbot","id":324515,"avatar_url":"https://avatars.githubusercontent.com/u/324515?v=3","gravatar_id":"","url":"https://api.github.com/users/buildbot","html_url":"https://github.com/buildbot","followers_url":"https://api.github.com/users/buildbot/followers","following_url":"https://api.github.com/users/buildbot/following{/other_user}","gists_url":"https://api.github.com/users/buildbot/gists{/gist_id}","starred_url":"https://api.github.com/users/buildbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buildbot/subscriptions","organizations_url":"https://api.github.com/users/buildbot/orgs","repos_url":"https://api.github.com/users/buildbot/repos","events_url":"https://api.github.com/users/buildbot/events{/privacy}","received_events_url":"https://api.github.com/users/buildbot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/buildbot/buildbot","description":"Python-based continuous integration testing framework; your pull requests are more than welcome!","fork":false,"url":"https://api.github.com/repos/buildbot/buildbot","forks_url":"https://api.github.com/repos/buildbot/buildbot/forks","keys_url":"https://api.github.com/repos/buildbot/buildbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/buildbot/buildbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/buildbot/buildbot/teams","hooks_url":"https://api.github.com/repos/buildbot/buildbot/hooks","issue_events_url":"https://api.github.com/repos/buildbot/buildbot/issues/events{/number}","events_url":"https://api.github.com/repos/buildbot/buildbot/events","assignees_url":"https://api.github.com/repos/buildbot/buildbot/assignees{/user}","branches_url":"https://api.github.com/repos/buildbot/buildbot/branches{/branch}","tags_url":"https://api.github.com/repos/buildbot/buildbot/tags","blobs_url":"https://api.github.com/repos/buildbot/buildbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/buildbot/buildbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/buildbot/buildbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/buildbot/buildbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/buildbot/buildbot/statuses/{sha}","languages_url":"https://api.github.com/repos/buildbot/buildbot/languages","stargazers_url":"https://api.github.com/repos/buildbot/buildbot/stargazers","contributors_url":"https://api.github.com/repos/buildbot/buildbot/contributors","subscribers_url":"https://api.github.com/repos/buildbot/buildbot/subscribers","subscription_url":"https://api.github.com/repos/buildbot/buildbot/subscription","commits_url":"https://api.github.com/repos/buildbot/buildbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/buildbot/buildbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/buildbot/buildbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/buildbot/buildbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/buildbot/buildbot/contents/{+path}","compare_url":"https://api.github.com/repos/buildbot/buildbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/buildbot/buildbot/merges","archive_url":"https://api.github.com/repos/buildbot/buildbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/buildbot/buildbot/downloads","issues_url":"https://api.github.com/repos/buildbot/buildbot/issues{/number}","pulls_url":"https://api.github.com/repos/buildbot/buildbot/pulls{/number}","milestones_url":"https://api.github.com/repos/buildbot/buildbot/milestones{/number}","notifications_url":"https://api.github.com/repos/buildbot/buildbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/buildbot/buildbot/labels{/name}","releases_url":"https://api.github.com/repos/buildbot/buildbot/releases{/id}","created_at":"2010-07-06T17:56:53Z","updated_at":"2015-07-09T16:44:18Z","pushed_at":"2015-07-09T16:31:29Z","git_url":"git://github.com/buildbot/buildbot.git","ssh_url":"git@github.com:buildbot/buildbot.git","clone_url":"https://github.com/buildbot/buildbot.git","svn_url":"https://github.com/buildbot/buildbot","homepage":"http://buildbot.net","size":51624,"stargazers_count":1625,"watchers_count":1625,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":727,"mirror_url":null,"open_issues_count":34,"forks":727,"open_issues":34,"watchers":1625,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1764"},"html":{"href":"https://github.com/buildbot/buildbot/pull/1764"},"issue":{"href":"https://api.github.com/repos/buildbot/buildbot/issues/1764"},"comments":{"href":"https://api.github.com/repos/buildbot/buildbot/issues/1764/comments"},"review_comments":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1764/comments"},"review_comment":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1764/commits"},"statuses":{"href":"https://api.github.com/repos/buildbot/buildbot/statuses/7c726bb9ed846ab9a83abc1c8a2163f1183d40c0"}}}}