Skip to content
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

Python 2 / 3 compatibility changes #263

Merged
merged 7 commits into from
Mar 18, 2019
Merged

Conversation

catleeball
Copy link
Contributor

@walkerjoe and I made several small fixes to help apitools be cross-compatible with Python 2 and 3. These issues were identified while working on making gsutil's py-six-current branch compatible with Python 2.7 and 3.5+. This was done under the guidance of @houglum

Notably, we're using the six library to help ensure byte strings vs unicode strings work together nicely.

Email generator had some small text encoding issues with generating text in Python 3.5+, so we added MultipartBytesGenerator method to alleviate the issue.

Let us know if you have any questions about these changes! 🙂

walkerjoe and others added 6 commits January 18, 2019 16:07
Most instances require binary text but a few require unicode string in
python 3.x.
Between Python 3.0 and 3.5, json.load and json.loads only accepted
unicode string format. Change was made in 3.6 to automatically adapt to
both unicode and bytes formats.

https://docs.python.org/3/whatsnew/3.6.html#json
Fix to MD5 hashing issue on Python 3.
@googlebot
Copy link
Collaborator

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

@catleeball
Copy link
Contributor Author

Note that both Joe and I have signed CLAs, but googlebot gets a little upset with multiple authors. ✍️

@houglum houglum self-requested a review March 18, 2019 22:23
@coveralls
Copy link

coveralls commented Mar 18, 2019

Coverage Status

Coverage decreased (-0.07%) to 91.675% when pulling a2ab79b on catleeball:py-six into 975e38a on google:master.

apitools/base/py/transfer.py Outdated Show resolved Hide resolved
apitools/base/protorpclite/protojson.py Show resolved Hide resolved
- Changed docstring to have appropriate spacing
- Changed docstring to be less then 80 chars long
- Updated six in setup.py to be >= v1.12
@houglum houglum added cla: yes and removed cla: no labels Mar 18, 2019
@googlebot
Copy link
Collaborator

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@houglum houglum merged commit f704b62 into google:master Mar 18, 2019
catleeball added a commit to catleeball/apitools that referenced this pull request Jun 4, 2019
* Using six.ensure_binary() in write command

* Updated response.content to be coerced to a string for stream.write.

* Adding exception block to catch streams that require string

Most instances require binary text but a few require unicode string in
python 3.x.

* Ensuring string format before json.loads()

Between Python 3.0 and 3.5, json.load and json.loads only accepted
unicode string format. Change was made in 3.6 to automatically adapt to
both unicode and bytes formats.

https://docs.python.org/3/whatsnew/3.6.html#json

* Cherrypicking ed's Changes - MultipartBytesGenerator

Fix to issue on Python 3 where certain sequences of bytes would be
incorrectly mutated (the generator would consider it a line ending that
needed to be changed to what it considered the "correct" characters).

* Linting fixes, updated dependency six version

- Changed docstring to have appropriate spacing
- Changed docstring to be less then 80 chars long
- Updated six in setup.py to be >= v1.12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants