mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 03:11:09 +00:00
Fix ContentFile.decoded_content for Python 3.0 to 3.2
This commit is contained in:
@@ -25,11 +25,15 @@
|
||||
################################################################################
|
||||
|
||||
import base64
|
||||
import sys
|
||||
|
||||
import github.GithubObject
|
||||
import github.Repository
|
||||
|
||||
|
||||
atLeastPython3 = sys.hexversion >= 0x03000000
|
||||
|
||||
|
||||
class ContentFile(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents ContentFiles as returned for example by http://developer.github.com/v3/todo
|
||||
@@ -46,7 +50,11 @@ class ContentFile(github.GithubObject.CompletableGithubObject):
|
||||
@property
|
||||
def decoded_content(self):
|
||||
assert self.encoding == "base64", "unsupported encoding: %s" % self.encoding
|
||||
return base64.b64decode(self.content)
|
||||
if atLeastPython3:
|
||||
content = bytearray(self.content, "utf-8") # pragma no cover (covered by tests with Python 3.2)
|
||||
else:
|
||||
content = self.content
|
||||
return base64.b64decode(content)
|
||||
|
||||
@property
|
||||
def encoding(self):
|
||||
|
||||
Reference in New Issue
Block a user