8000 Python 2 / 3 compatibility by kevin-brown · Pull Request #8 · gitpython-developers/async · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Apr 14, 2024. It is now read-only.

Python 2 / 3 compatibility #8

Merged
merged 2 commits into from
Jul 14, 2014
Merged

Python 2 / 3 compatibility #8

merged 2 commits into from
Jul 14, 2014

Conversation

kevin-brown
Copy link
Contributor

This pull request consists of two commits, one for some automated PEP 8 fixes and the other with the actual fixes. https://github.com/kevin-brown/async/commit/339024bfb1d0a2b091e63d7a7ea23a1c63189f5c is the main commit to focus on.

In gitdb under Python 2, when using the latest async commit, this could not be imported at all. This fixes the problems that came up, so now everything should work as it previously did.

This fixes the breaking changes for Python 2 that were made in the
last attempt and improves Python 3 compatibility a bit more.

Python 3 supports the new `file` argument to the `print` function
that allows you to specify where to print to.  In the code, this
was being used to print to stderr.  Unfortunately Python 2 does not
yet support this, so we are now using `sys.stderr.write` instead.

Python 2's `Queue` module was renamed to `queue` in Python 3.  We
should be importing them both to ensure that the code runs on both
versions.  By default, we are assuming that Python 3 will be used
and are using it as the first import before falling back to the old
name.

`threading._sleep` was a private method and was removed in Python 3.
It has been replaced by `time.sleep` for now, as that is both public
and consistent across versions.

When determining chunk sizes and the number of chunks, there was a
possibility of floating values being passed in or calculated.  To
ensure that the generated range does not throw an exception, we are
manually casting these to integers.

The iterator was previously changed so `next` became `__next__`,
which was the Python 3 method for the `next` function.  This adds
Python 2 compatibility alongside of these changes.
Byron added a commit that referenced this pull request Jul 14, 2014
Python 2 / 3 compatibility
@Byron Byron merged commit 3f26b05 into gitpython-developers:master Jul 14, 2014
@Byron
Copy link
Member
Byron commented Jul 14, 2014

Thank you very much !

@kevin-brown kevin-brown deleted the issue_5 branch July 16, 2014 22:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0