-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
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)
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.