Skip to content

Conversation

@tseaver
Copy link
Contributor

@tseaver tseaver commented Dec 5, 2016

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.

@tseaver tseaver added api: bigquery Issues related to the BigQuery API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 5, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 5, 2016
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.

Copy link
Contributor

@dhermes dhermes left a 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 tseaver merged commit 2cd042c into googleapis:master Dec 6, 2016
@tseaver tseaver deleted the 2815-bigquery-py3k-bytes-field branch December 6, 2016 02:09
@dhermes
Copy link
Contributor

dhermes commented Dec 6, 2016

@tseaver: See "but please use the core helper"

@tseaver
Copy link
Contributor Author

tseaver commented Dec 6, 2016

@dhermes I updated it (via git commit --amend) to do so.

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.

dhermes added a commit to dhermes/google-cloud-python that referenced this pull request Dec 6, 2016
dhermes added a commit that referenced this pull request Dec 6, 2016
Follow-up to #2818, use _to_bytes as intended in BigQuery.
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
…tes-field

Fix 'BYTES' field handling on Py3k.
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
Follow-up to googleapis#2818, use _to_bytes as intended in BigQuery.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the BigQuery API. cla: yes This human has signed the Contributor License Agreement. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants