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
2 files changed
tree: 12e5ade7e6b272c0b7e5b1e985f863e8515c4984
  1. apiclient/
  2. docs/
  3. googleapiclient/
  4. samples/
  5. static/
  6. tests/
  7. tools/
  8. .coveragerc
  9. .gitignore
  10. .gitmodules
  11. .hgignore
  12. .travis.yml
  13. CHANGELOG
  14. describe.py
  15. expandsymlinks.py
  16. LICENSE
  17. Makefile
  18. MANIFEST.in
  19. README.md
  20. samples-index.py
  21. setup.py
  22. sitecustomize.py
  23. tox.ini
README.md

About

This is the Python client library for Google's discovery based APIs. To get started, please see the full documentation for this library. Additionally, dynamically generated documentation is available for all of the APIs supported by this library.

Installation

To install, simply use pip or easy_install:

$ pip install --upgrade google-api-python-client

or

$ easy_install --upgrade google-api-python-client

See the Developers Guide for more detailed instructions and additional documentation.

Python Version

Python 2.6 or 2.7 are fully supported.

Python 3.3+ is also now supported! However, this library has not yet been used as thoroughly with Python 3, so we'd recommend testing before deploying with Python 3 in production.

Third Party Libraries and Dependencies

The following libraries will be installed when you install the client library:

For development you will also need the following libraries:

Contributing

Please see the contributing page for more information. In particular, we love pull requests - but please make sure to sign the contributor license agreement.