Fix non-resumable binary uploads on Python 3
1. Generator and StringIO are replaced by BytesGenerator and BytesIO.
If BytesGenerator doesn't exist (as is the case in Python 2), fall
back to Generator.
2. BytesGenerator is buggy [1] [2] and corrupts '\r' into '\n'. To
work around this, we implement a patched version of BytesGenerator
that replaces ._write_lines with just .write.
The test_multipart_media_good_upload has been updated to reflect the
change. It is also stricter now, as it matches the entire request body
against the expected form.
Note: BytesGenerator was introduced in Python 3.2. This is OK since the
library already demands 3.3+.
Fixes #145.
[1]: https://bugs.python.org/issue18886
[2]: https://bugs.python.org/issue19003
Loading
Please sign in to comment