Skip to content

Make sure .read() and friends always return bytes #405

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

Merged
merged 2 commits into from
Apr 10, 2016
Merged

Make sure .read() and friends always return bytes #405

merged 2 commits into from
Apr 10, 2016

Conversation

nvie
Copy link
Contributor

@nvie nvie commented Apr 6, 2016

This had tripped me up when consuming from .read(4096) in a streaming fashion. All chunks will return bytes except the last one (the empty string), which is a unicode string in Python 3.

This fixes that to always return bytes, in both Python 2 and 3.

@Byron Byron added this to the v1.0.3 - Fixes milestone Apr 7, 2016
@Byron
Copy link
Member

Byron commented Apr 7, 2016

Thanks @nvie , much appreciated !
It seems it works well in python 2.x, but apparently the test itself has wrong expectations and thus fails in py3.x.
Do you think changing this line to assert s.readline() == b'' will do it ?

@nvie
Copy link
Contributor Author

nvie commented Apr 7, 2016

I've fixed the tests as you indicated. I had some trouble running the tests locally (I just tried running tox, but it failed on different tests, not this one). My local tests are still failing, not sure why. I'll await Travis' response now and adjust accordingly.

Thanks for this awesome project, @Byron!

@nvie
Copy link
Contributor Author

nvie commented Apr 7, 2016

Seems all good now :)

@Byron Byron merged commit 9debf6b into gitpython-developers:master Apr 10, 2016
@Byron
Copy link
Member

Byron commented Apr 10, 2016

Thanks @nvie ! Testing locally usually fails when you are on a branch. Reason for this is that GitPython uses its own git repository for read-only testing, but doesn't really deal with the edge-cases arising from it. Bad practice, I know :).

Besides: I still remember when I was first studying this git-flow page that so neatly visualised the branching scheme that so many are using today ! Thus it's great to have your name in this project's commit history :) !

@nvie
Copy link
Contributor Author

nvie commented Apr 12, 2016

Thanks, that's great to hear. As the matter of fact, we're starting to use more and more of GitPython, and we're seeing some wild repositories, so expect more contributions in the future. First one is #408 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants