Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Adding _from_bytes helpers as a foil for _to_bytes. #272

Merged
merged 2 commits into from
Aug 19, 2015

Conversation

dhermes
Copy link
Contributor

@dhermes dhermes commented Aug 14, 2015

@nathanielmanistaatgoogle This is the child of #157.

I labeled it don't merge because I essentially just looked around for .decode and tried to preserve a lot of the stuff from the other PR, but haven't written any new tests.

Let's discuss (and I'll iterate) before merging.

UPDATE: I should note that I rebased the original PR if anyone wants to have a look: https://github.com/dhermes/oauth2client/tree/pr-157-rebased

Fixes #239 (but no tests yet tested by AssertionCredentialsTests.test_refresh_success_bytes)

@dhermes
Copy link
Contributor Author

dhermes commented Aug 14, 2015

I should also FYI to @saaros that this is happening

@@ -279,8 +280,7 @@ def new_from_json(cls, s):
An instance of the subclass of Credentials that was serialized with
to_json().
"""
if isinstance(s, bytes):
s = s.decode('utf-8')
s = _from_bytes(s)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@nathanielmanistaatgoogle
Copy link
Contributor

Looks mostly good; what else do you want to do here?

New _from_bytes behavior warrants update to docstring. Also
updated 1-letter or other non-descriptive variable names.
@dhermes
Copy link
Contributor Author

dhermes commented Aug 17, 2015

@nathanielmanistaatgoogle Sent the new commit.

I was looking for places that might need testing but kind of realized that the whole reason we test _from_bytes with all inputs is so that we don't have to send each of those types through every single code path which hits _from_bytes.

Also note I massively updated the Credentials.new_from_json method but left s as the only argument. This is because it is part of the public interface, so people can execute

Credentials.new_from_json(s=file_obj.read())

@nathanielmanistaatgoogle
Copy link
Contributor

Looks good to me - anything remaining to be done here before merge? Anyone else who should review this?

@dhermes
Copy link
Contributor Author

dhermes commented Aug 19, 2015

No and no. Merging.

dhermes added a commit that referenced this pull request Aug 19, 2015
Adding _from_bytes helpers as a foil for _to_bytes.
@dhermes dhermes merged commit 043e066 into googleapis:master Aug 19, 2015
@dhermes dhermes deleted the add-from-bytes branch August 19, 2015 04:10
@dhermes dhermes mentioned this pull request Aug 26, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants