Closed
Description
The discovery.build_from_document
function assumes that service
is of type str
, however when running in Python3 instead of str
it can be of type bytes
.
Because of this wrong assumption, the function fails on line 337 where the bytes string is compared to an actual text string.
The google-api-python-client version where i've seen this problem is 1.7.7
Solution
Add a check, if service is a bytes string convert it using UTF-8 format
if isinstance(service, six.string_types):
service = json.loads(service)
+ elif isinstance(service, six.binary_type):
+ service = json.loads(service.decode('utf8'))
This fixes my problem (observed when using this library in Google3)