Uh oh!
There was an error while loading. Please reload this page.
Ensure that mulitpart bodies are always bytes. - #1779
Conversation
tseaver
commented
May 6, 2016
Note that opening the file passed to |
| def _email_chunk_parser(): | ||
| import six | ||
| if six.PY3: # pragma: NO COVER Python3 | ||
| from email.parser import BytesParser # pylint: disable=E0611 |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
dhermes
commented
May 6, 2016
RE: Always failing tables, couldn't we just convert to bytes? Then instead of documenting "this will fail", we'd document "if you don't give us bytes, we're going to guess your encoding and we might get it wrong" |
tseaver
commented
May 6, 2016
Do we want to be in the business of reading potentially huge files in memory and guessing their encoding? If we want to try checking for 'stream.mode != 'rb'` (assuming they opened it, rather than passing us some other file-like object) we could raise an exception right away, rather than failing with a much uglier traceback later. |
As discovered in googleapis/google-cloud-python#1760, we were mangling bytes when encoding them as part of a multipart upload request. The fix is to switch from using `six.StringIO` to `six.BytesIO` in `transfer.py`. The patch here is closely based on googleapis/google-cloud-python#1779.
tseaver
commented
May 10, 2016
I agree that guessing the format is probably a bad idea (because while it might make some people happy, it might make some other people really really mad). Can we have a super clear exception saying ... "You gave us a file opened in text mode, which means we don't know the encoding... Can you open in binary mode with the right encoding?" |
dhermes
commented
May 11, 2016
Sorry for the delay. @tseaver I agree with you, sniffing the entire file was ill-conceived. |
| if six.PY3: # pragma: NO COVER Python3 | ||
| # pylint: disable=no-name-in-module | ||
| from email.parser import BytesParser | ||
| # pylint: enable=no-name-in-module |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Addresses: #1779 (comment)
On 'master', it is now disabled globally.
tseaver
commented
May 11, 2016
IFF the user gives us an actual file object (created via |
jgeewax
commented
May 11, 2016
@dhermes And in that case, we just do our best here, right? |
tseaver
commented
May 11, 2016
tseaver
commented
May 12, 2016
dhermes
commented
May 12, 2016
LGTM |
…#1779) * Fixed name of model * update model ids
…#1779) * Fixed name of model * update model ids
…#1779) * Fixed name of model * update model ids
Source-Link: https://togithub.com/googleapis/synthtool/commit/fac8444edd5f5526e804c306b766a271772a3e2f Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:5ea6d0ab82c956b50962f91d94e206d3921537ae5fe1549ec5326381d8905cfa
Loosely based on @joar's gist
Fixes#1760.