-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 'BYTES' field handling on Py3k. #2818
Fix 'BYTES' field handling on Py3k. #2818
Conversation
@@ -57,7 +59,9 @@ def _string_from_json(value, _): | |||
def _bytes_from_json(value, field): | |||
"""Base64-decode value""" | |||
if _not_null(value, field): | |||
return base64.decodestring(value) | |||
return base64.decodestring( | |||
value.encode('ascii') if isinstance(value, six.text_type) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please use the core helper
JSON decodes the base64-encoded bits as text, which cannot be passed to 'base64.decodestring' on Py3k.
@tseaver: See "but please use the core helper" |
@dhermes I updated it (via |
@@ -57,7 +60,8 @@ def _string_from_json(value, _): | |||
def _bytes_from_json(value, field): | |||
"""Base64-decode value""" | |||
if _not_null(value, field): | |||
return base64.decodestring(value) | |||
return base64.decodestring( | |||
_to_bytes(value) if isinstance(value, six.text_type) else value) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Follow-up to #2818, use _to_bytes as intended in BigQuery.
…tes-field Fix 'BYTES' field handling on Py3k.
Follow-up to googleapis#2818, use _to_bytes as intended in BigQuery.
JSON decodes the base64-encoded bits as text, which cannot be passed to 'base64.decodestring' on Py3k.
tox -e system-tests3
was failing for me locally before this patch, and passes with it.