Remove some uses of atLeastPython3 (#1191)

There are a number of call sites that would behave differently depending
on Python 2 or 3. A fair amount of them are left over from Python 3.2 or
Python 2.6 were the current versions, and it was much harder to write
compatible code for both versions. Happily, that is now in the past, so
refactor some of them out.
This commit is contained in:
Steve Kowalik
2019-08-05 16:14:39 +10:00
committed by GitHub
parent f93207b4ca
commit cca8e3a5b4
3 changed files with 6 additions and 22 deletions
+1 -8
View File
@@ -39,9 +39,6 @@ import github.GithubObject
import github.Repository
atLeastPython3 = sys.hexversion >= 0x03000000
class ContentFile(github.GithubObject.CompletableGithubObject):
"""
This class represents ContentFiles. The reference can be found here https://developer.github.com/v3/repos/contents/#get-contents
@@ -61,11 +58,7 @@ class ContentFile(github.GithubObject.CompletableGithubObject):
@property
def decoded_content(self):
assert self.encoding == "base64", "unsupported encoding: %s" % self.encoding
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)
return base64.b64decode(bytearray(self.content, "utf-8"))
@property
def download_url(self):