-
Notifications
You must be signed in to change notification settings - Fork 66
Fix deprecated calls for Python 3.9 #53
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
Conversation
gitdb/pack.py
Outdated
@@ -410,7 +419,7 @@ def offsets(self): | |||
if self._version == 2: | |||
# read stream to array, convert to tuple | |||
a = array.array('I') # 4 byte unsigned int, long are 8 byte on 64 bit it appears | |||
a.fromstring(buffer(self._cursor.map(), self._pack_offset, self._pack_64_offset - self._pack_offset)) | |||
_frombytes(a, buffer(self._cursor.map(), self._pack_offset, self._pack_64_offset - self._pack_offset)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be simpler:
a = array.array('I', buffer(self._cursor.map(), self._pack_offset, self._pack_64_offset - self._pack_offset))
Or maybe even use memoryview(self._cursor.map())[self._pack_offset : self._pack_64_offset]
instead of buffer(...)
(not tested).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your contribution, it's very much appreciated.
I have left a few comments and will merge as soon as Python 2 compatibility is removed.
The array methods fromstring/tostring have been deprecated since Python 3.2. Python 3.9 removes them completely. This was discovered when trying to build gitdb package for Fedora 33. https://bugzilla.redhat.com/show_bug.cgi?id=1788660
9653f31
to
7729239
Compare
I updated the code to drop Python 2 compatibility. |
Thanks a lot for your contribution! I will cut release v3.0 soon! |
The array methods fromstring/tostring have been deprecated since Python 3.2. Python 3.9 removes them completely.
This was discovered when trying to build gitdb package for Fedora 33.
https://bugzilla.redhat.com/show_bug.cgi?id=1788660