Skip to content

Commit 32fe44d

Browse files
committed
No need for unicode→str kwargs hack in Python 3.
1 parent 9ea7e4c commit 32fe44d

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

github2/core.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,26 @@ def get_value(self, *args, **kwargs):
158158
datatype = kwargs.pop("datatype", None)
159159
value = self.make_request(*args, **kwargs)
160160
if datatype:
161-
# unicode keys are not accepted as kwargs by python, see:
162-
#http://mail-archives.apache.org/mod_mbox/qpid-dev/200609.mbox/%3C1159389941.4505.10.camel@localhost.localdomain%3E
163-
# So we make a local dict with the same keys but as strings:
164-
return datatype(**dict((str(k), v) for (k, v) in value.iteritems()))
161+
if not PY3K:
162+
# unicode keys are not accepted as kwargs by python, see:
163+
#http://mail-archives.apache.org/mod_mbox/qpid-dev/200609.mbox/%3C1159389941.4505.10.camel@localhost.localdomain%3E
164+
# So we make a local dict with the same keys but as strings:
165+
return datatype(**dict((str(k), v) for (k, v) in value.items()))
166+
else:
167+
return datatype(**value)
165168
return value
166169

167170
def get_values(self, *args, **kwargs):
168171
datatype = kwargs.pop("datatype", None)
169172
values = self.make_request(*args, **kwargs)
170173
if datatype:
171-
# Same as above, unicode keys will blow up in **args, so we need to
172-
# create a new 'values' dict with string keys
173-
return [datatype(**dict((str(k), v) for (k, v) in value.iteritems()))
174-
for value in values]
174+
if not PY3K:
175+
# Same as above, unicode keys will blow up in **args, so we need to
176+
# create a new 'values' dict with string keys
177+
return [datatype(**dict((str(k), v) for (k, v) in value.items()))
178+
for value in values]
179+
else:
180+
return [datatype(**value) for value in values]
175181
else:
176182
return values
177183

0 commit comments

Comments
 (0)