-
Notifications
You must be signed in to change notification settings - Fork 225
Fixed #299 -- work on very old python2.7s :-( #300
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
FWIW, I structured the code like this so we only have the overhead of creating the |
Looks like a really simple patch that's easy to remove when 2.7 support is dropped. |
Thanks! |
@@ -234,6 +234,12 @@ def __init__(self, file_like=None, read_size=0, use_list=True, raw=True, | |||
|
|||
#: array of bytes fed. | |||
self._buffer = bytearray() | |||
# Some very old pythons don't support `struct.unpack_from()` with a | |||
# `bytearray`. So we wrap it in a `buffer()` there. | |||
if sys.version_info < (2, 7, 6): |
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.
Note that the issue occurs on OSX with python 2.7.10... apparently this fix will not apply to OSX's /usr/bin/python
~: /usr/bin/python -c 'import sys; print(sys.version_info)'
sys.version_info(major=2, minor=7, micro=10, releaselevel='final', serial=0)
Interesting, I wasn't able to reproduce this with a 2.7.6 from Ubuntu so I
assumed that anything older was unaffected, that's unexpected.
…On Mon, Apr 16, 2018 at 5:57 PM, Zoran Simic ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In msgpack/fallback.py
<#300 (comment)>
:
> @@ -234,6 +234,12 @@ def __init__(self, file_like=None, read_size=0, use_list=True, raw=True,
#: array of bytes fed.
self._buffer = bytearray()
+ # Some very old pythons don't support `struct.unpack_from()` with a
+ # `bytearray`. So we wrap it in a `buffer()` there.
+ if sys.version_info < (2, 7, 6):
Note that the issue occurs on OSX with python 2.7.10... apparently this
fix will not apply to OSX's /usr/bin/python
~: /usr/bin/python -c 'import sys; print(sys.version_info)'
sys.version_info(major=2, minor=7, micro=10, releaselevel='final', serial=0)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#300 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAADBAzV2PwMcoRNZJ3A4T8ximryHMlyks5tpRO7gaJpZM4TVSf2>
.
--
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: D1B3 ADC0 E023 8CA6
|
I noticed it on OSX, with system python 2.7.10
pypa/pip#5259
On Mon, Apr 16, 2018 at 2:58 PM, Alex Gaynor <[email protected]>
wrote:
… Interesting, I wasn't able to reproduce this with a 2.7.6 from Ubuntu so I
assumed that anything older was unaffected, that's unexpected.
On Mon, Apr 16, 2018 at 5:57 PM, Zoran Simic ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In msgpack/fallback.py
> <#300#
discussion_r181898068>
> :
>
> > @@ -234,6 +234,12 @@ def __init__(self, file_like=None, read_size=0,
use_list=True, raw=True,
>
> #: array of bytes fed.
> self._buffer = bytearray()
> + # Some very old pythons don't support `struct.unpack_from()` with a
> + # `bytearray`. So we wrap it in a `buffer()` there.
> + if sys.version_info < (2, 7, 6):
>
> Note that the issue occurs on OSX with python 2.7.10... apparently this
> fix will not apply to OSX's /usr/bin/python
>
> ~: /usr/bin/python -c 'import sys; print(sys.version_info)'
> sys.version_info(major=2, minor=7, micro=10, releaselevel='final',
serial=0)
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#300#
pullrequestreview-112604053>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/
AAADBAzV2PwMcoRNZJ3A4T8ximryHMlyks5tpRO7gaJpZM4TVSf2>
> .
>
--
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: D1B3 ADC0 E023 8CA6
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#300 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAtmvYpcYXrgqwYrcAnqD1_OYby8zxSRks5tpRP6gaJpZM4TVSf2>
.
|
On 10.13.4 (High Sierra),
unpack_from supports bytearray. |
On 10.12.6 (Sierra):
@zsimic Is your python really 2.7.10? |
You're right @methane it does work with stock python 2.7.10 I have a pyenv-installed 2.7.0 (it's a recent pyenv install, don't know why it picked 2.7.0), and 2.7.0 was selected when I observed the issue, not my system python. Sorry about the confusion |
Tested on debian wheezy (which is a royal PITA). There's some other failing tests (all related to
memoryview(array.array(...))
), but this fixes all of the exceptions seen in #299