From 5404030119b243a5adc04cc1e74debfad25fbcb1 Mon Sep 17 00:00:00 2001 From: ghfan Date: Wed, 10 Aug 2016 20:33:20 +0800 Subject: [PATCH] change file content encoding to support unicode(like chinese), py2 --- github/Repository.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/github/Repository.py b/github/Repository.py index 19b1fcc3..2e3ac2ac 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -1269,6 +1269,8 @@ class Repository(github.GithubObject.CompletableGithubObject): if atLeastPython3: content = b64encode(content.encode('utf-8')).decode('utf-8') else: + if isinstance(content, unicode): + content = content.encode('utf-8') content = b64encode(content) put_parameters = {'message': message, 'content': content} @@ -1324,6 +1326,8 @@ class Repository(github.GithubObject.CompletableGithubObject): if atLeastPython3: content = b64encode(content.encode('utf-8')).decode('utf-8') else: + if isinstance(content, unicode): + content = content.encode('utf-8') content = b64encode(content) put_parameters = {'message': message, 'content': content,