diff --git a/github/GithubObject.py b/github/GithubObject.py index 6cf8c7ac..cd8b7d02 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -220,7 +220,10 @@ class GithubObject(object): else: items = list(params.items()) for k, v in sorted(items, key=itemgetter(0), reverse=True): - yield '{k}="{v}"'.format(k=k, v=v) if isinstance(v, (str, unicode)) else '{k}={v}'.format(k=k, v=v) + isText = isinstance(v, (str, unicode)) + if isText and not atLeastPython3: + v = v.encode('utf-8') + yield '{k}="{v}"'.format(k=k, v=v) if isText else '{k}={v}'.format(k=k, v=v) return '{class_name}({params})'.format( class_name=self.__class__.__name__, params=", ".join(list(format_params(params))) diff --git a/github/tests/AllTests.py b/github/tests/AllTests.py index 266cdf95..812a7a0b 100644 --- a/github/tests/AllTests.py +++ b/github/tests/AllTests.py @@ -93,3 +93,4 @@ from Issue174 import * from Issue214 import * from Issue216 import * from Issue278 import * +from Issue494 import * diff --git a/github/tests/Issue494.py b/github/tests/Issue494.py new file mode 100644 index 00000000..7062a9d2 --- /dev/null +++ b/github/tests/Issue494.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +# ########################## Copyrights and license ############################ +# # +# Copyright 2013 Vincent Jacques # +# Copyright 2016 Sam Corbett # +# # +# This file is part of PyGithub. # +# http://pygithub.github.io/PyGithub/v1/index.html # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +# ############################################################################## + +import Framework + + +class Issue494(Framework.TestCase): + def setUp(self): + Framework.TestCase.setUp(self) + self.repo = self.g.get_repo("apache/brooklyn-server") + self.pull = self.repo.get_pull(465) + + def testRepr(self): + expected = 'PullRequest(title="Change SetHostnameCustomizer to check if ' \ + '/etc/sysconfig/network exist…", number=465)' + self.assertEqual(self.pull.__repr__(), expected) diff --git a/github/tests/ReplayData/Issue494.setUp.txt b/github/tests/ReplayData/Issue494.setUp.txt new file mode 100644 index 00000000..688cbd31 --- /dev/null +++ b/github/tests/ReplayData/Issue494.setUp.txt @@ -0,0 +1,11 @@ +https +GET +api.github.com +None +/repos/apache/brooklyn-server/pulls/465 +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '15049'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-served-by', '7b641bda7ec2ca7cd9df72d2578baf75'), ('x-oauth-scopes', 'public_repo'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"fde80d800fc318ecf3ec43cdee7b8719"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4999'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', '569898E3:14C7:97463B5:583DDA4C'), ('last-modified', 'Fri, 25 Nov 2016 13:15:31 GMT'), ('date', 'Tue, 29 Nov 2016 19:43:08 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1480452188')] +{"url":"https://api.github.com/repos/apache/brooklyn-server/pulls/465","id":95300332,"html_url":"https://github.com/apache/brooklyn-server/pull/465","diff_url":"https://github.com/apache/brooklyn-server/pull/465.diff","patch_url":"https://github.com/apache/brooklyn-server/pull/465.patch","issue_url":"https://api.github.com/repos/apache/brooklyn-server/issues/465","number":465,"state":"closed","locked":false,"title":"Change SetHostnameCustomizer to check if /etc/sysconfig/network exist…","user":{"login":"iyovcheva","id":4160133,"avatar_url":"https://avatars.githubusercontent.com/u/4160133?v=3","gravatar_id":"","url":"https://api.github.com/users/iyovcheva","html_url":"https://github.com/iyovcheva","followers_url":"https://api.github.com/users/iyovcheva/followers","following_url":"https://api.github.com/users/iyovcheva/following{/other_user}","gists_url":"https://api.github.com/users/iyovcheva/gists{/gist_id}","starred_url":"https://api.github.com/users/iyovcheva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iyovcheva/subscriptions","organizations_url":"https://api.github.com/users/iyovcheva/orgs","repos_url":"https://api.github.com/users/iyovcheva/repos","events_url":"https://api.github.com/users/iyovcheva/events{/privacy}","received_events_url":"https://api.github.com/users/iyovcheva/received_events","type":"User","site_admin":false},"body":"…s on machine and create it if not\r\n\r\nIn some rare situations it's possible `/etc/sysconfig/network` to be missing on the VM on CentOS 6.\r\nChanged the behavior of `SetHostnameCustomizer` to check and create the file.","created_at":"2016-11-25T12:54:37Z","updated_at":"2016-11-25T13:15:31Z","closed_at":"2016-11-25T13:01:03Z","merged_at":null,"merge_commit_sha":"2ecd02721a0b2920bc2ea333a7a3ce4d74458f19","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/brooklyn-server/pulls/465/commits","review_comments_url":"https://api.github.com/repos/apache/brooklyn-server/pulls/465/comments","review_comment_url":"https://api.github.com/repos/apache/brooklyn-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/brooklyn-server/issues/465/comments","statuses_url":"https://api.github.com/repos/apache/brooklyn-server/statuses/68fd4d17d44ff9f16a59d8dd18f48fba3b5b38a5","head":{"label":"iyovcheva:set-hostname-customizer","ref":"set-hostname-customizer","sha":"68fd4d17d44ff9f16a59d8dd18f48fba3b5b38a5","user":{"login":"iyovcheva","id":4160133,"avatar_url":"https://avatars.githubusercontent.com/u/4160133?v=3","gravatar_id":"","url":"https://api.github.com/users/iyovcheva","html_url":"https://github.com/iyovcheva","followers_url":"https://api.github.com/users/iyovcheva/followers","following_url":"https://api.github.com/users/iyovcheva/following{/other_user}","gists_url":"https://api.github.com/users/iyovcheva/gists{/gist_id}","starred_url":"https://api.github.com/users/iyovcheva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iyovcheva/subscriptions","organizations_url":"https://api.github.com/users/iyovcheva/orgs","repos_url":"https://api.github.com/users/iyovcheva/repos","events_url":"https://api.github.com/users/iyovcheva/events{/privacy}","received_events_url":"https://api.github.com/users/iyovcheva/received_events","type":"User","site_admin":false},"repo":{"id":51428490,"name":"brooklyn-server","full_name":"iyovcheva/brooklyn-server","owner":{"login":"iyovcheva","id":4160133,"avatar_url":"https://avatars.githubusercontent.com/u/4160133?v=3","gravatar_id":"","url":"https://api.github.com/users/iyovcheva","html_url":"https://github.com/iyovcheva","followers_url":"https://api.github.com/users/iyovcheva/followers","following_url":"https://api.github.com/users/iyovcheva/following{/other_user}","gists_url":"https://api.github.com/users/iyovcheva/gists{/gist_id}","starred_url":"https://api.github.com/users/iyovcheva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iyovcheva/subscriptions","organizations_url":"https://api.github.com/users/iyovcheva/orgs","repos_url":"https://api.github.com/users/iyovcheva/repos","events_url":"https://api.github.com/users/iyovcheva/events{/privacy}","received_events_url":"https://api.github.com/users/iyovcheva/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iyovcheva/brooklyn-server","description":"Mirror of Apache Brooklyn server","fork":true,"url":"https://api.github.com/repos/iyovcheva/brooklyn-server","forks_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/forks","keys_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/teams","hooks_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/hooks","issue_events_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/issues/events{/number}","events_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/events","assignees_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/assignees{/user}","branches_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/branches{/branch}","tags_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/tags","blobs_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/statuses/{sha}","languages_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/languages","stargazers_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/stargazers","contributors_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/contributors","subscribers_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/subscribers","subscription_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/subscription","commits_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/contents/{+path}","compare_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/merges","archive_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/downloads","issues_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/issues{/number}","pulls_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/pulls{/number}","milestones_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/milestones{/number}","notifications_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/labels{/name}","releases_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/releases{/id}","deployments_url":"https://api.github.com/repos/iyovcheva/brooklyn-server/deployments","created_at":"2016-02-10T08:15:16Z","updated_at":"2016-02-10T08:15:26Z","pushed_at":"2016-11-25T12:50:52Z","git_url":"git://github.com/iyovcheva/brooklyn-server.git","ssh_url":"git@github.com:iyovcheva/brooklyn-server.git","clone_url":"https://github.com/iyovcheva/brooklyn-server.git","svn_url":"https://github.com/iyovcheva/brooklyn-server","homepage":null,"size":32053,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"870986bd96d1fc15d66ca3f249ae86dbc93eafc7","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":47246081,"name":"brooklyn-server","full_name":"apache/brooklyn-server","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/brooklyn-server","description":"Mirror of Apache Brooklyn server","fork":false,"url":"https://api.github.com/repos/apache/brooklyn-server","forks_url":"https://api.github.com/repos/apache/brooklyn-server/forks","keys_url":"https://api.github.com/repos/apache/brooklyn-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/brooklyn-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/brooklyn-server/teams","hooks_url":"https://api.github.com/repos/apache/brooklyn-server/hooks","issue_events_url":"https://api.github.com/repos/apache/brooklyn-server/issues/events{/number}","events_url":"https://api.github.com/repos/apache/brooklyn-server/events","assignees_url":"https://api.github.com/repos/apache/brooklyn-server/assignees{/user}","branches_url":"https://api.github.com/repos/apache/brooklyn-server/branches{/branch}","tags_url":"https://api.github.com/repos/apache/brooklyn-server/tags","blobs_url":"https://api.github.com/repos/apache/brooklyn-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/brooklyn-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/brooklyn-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/brooklyn-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/brooklyn-server/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/brooklyn-server/languages","stargazers_url":"https://api.github.com/repos/apache/brooklyn-server/stargazers","contributors_url":"https://api.github.com/repos/apache/brooklyn-server/contributors","subscribers_url":"https://api.github.com/repos/apache/brooklyn-server/subscribers","subscription_url":"https://api.github.com/repos/apache/brooklyn-server/subscription","commits_url":"https://api.github.com/repos/apache/brooklyn-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/brooklyn-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/brooklyn-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/brooklyn-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/brooklyn-server/contents/{+path}","compare_url":"https://api.github.com/repos/apache/brooklyn-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/brooklyn-server/merges","archive_url":"https://api.github.com/repos/apache/brooklyn-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/brooklyn-server/downloads","issues_url":"https://api.github.com/repos/apache/brooklyn-server/issues{/number}","pulls_url":"https://api.github.com/repos/apache/brooklyn-server/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/brooklyn-server/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/brooklyn-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/brooklyn-server/labels{/name}","releases_url":"https://api.github.com/repos/apache/brooklyn-server/releases{/id}","deployments_url":"https://api.github.com/repos/apache/brooklyn-server/deployments","created_at":"2015-12-02T08:00:06Z","updated_at":"2016-11-01T11:09:27Z","pushed_at":"2016-11-29T17:32:56Z","git_url":"git://github.com/apache/brooklyn-server.git","ssh_url":"git@github.com:apache/brooklyn-server.git","clone_url":"https://github.com/apache/brooklyn-server.git","svn_url":"https://github.com/apache/brooklyn-server","homepage":null,"size":33116,"stargazers_count":13,"watchers_count":13,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":40,"mirror_url":"git://git.apache.org/brooklyn-server.git","open_issues_count":19,"forks":40,"open_issues":19,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/brooklyn-server/pulls/465"},"html":{"href":"https://github.com/apache/brooklyn-server/pull/465"},"issue":{"href":"https://api.github.com/repos/apache/brooklyn-server/issues/465"},"comments":{"href":"https://api.github.com/repos/apache/brooklyn-server/issues/465/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/brooklyn-server/pulls/465/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/brooklyn-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/brooklyn-server/pulls/465/commits"},"statuses":{"href":"https://api.github.com/repos/apache/brooklyn-server/statuses/68fd4d17d44ff9f16a59d8dd18f48fba3b5b38a5"}},"merged":false,"mergeable":true,"mergeable_state":"unstable","merged_by":null,"comments":1,"review_comments":0,"commits":1,"additions":32,"deletions":7,"changed_files":1} +