Remove more Python version specific code (#1193)

Remove a bunch of other call sites that behaved differently between
Python 2 and 3, massively cleaning up a few messy methods.
This commit is contained in:
Steve Kowalik
2019-08-28 15:24:54 +10:00
committed by GitHub
parent 7bac694ae5
commit a0f01cf9cf
9 changed files with 44 additions and 94 deletions
+7 -9
View File
@@ -33,7 +33,6 @@
################################################################################
from __future__ import absolute_import
import sys
import datetime
from operator import itemgetter
@@ -41,8 +40,6 @@ from . import GithubException
from . import Consts
import six
atLeastPython3 = sys.hexversion >= 0x03000000
class _NotSetType:
def __repr__(self):
@@ -233,13 +230,14 @@ class GithubObject(object):
def format_params(params):
items = list(params.items())
for k, v in sorted(items, key=itemgetter(0), reverse=True):
isText = isinstance(v, (str, six.text_type))
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(
if isinstance(v, bytes):
v = v.decode('utf-8')
if isinstance(v, six.text_type):
v = u'"{v}"'.format(v=v)
yield u'{k}={v}'.format(k=k, v=v)
return u'{class_name}({params})'.format(
class_name=self.__class__.__name__,
params=", ".join(list(format_params(params)))
params=u", ".join(list(format_params(params)))
)