Last active
June 22, 2017 17:23
-
-
Save popravich/f52cb9919b9ed19820aff0e2348df0ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ python --version | |
#Python 3.5.3 (a39af0be3a22, Jun 05 2017, 20:18:00) | |
#[PyPy 5.8.0-beta0 with GCC 6.2.0 20160901] | |
# | |
# The problem has been discovered here: | |
# https://travis-ci.org/aio-libs/aioredis/jobs/245293341 | |
# | |
# TL;DR: | |
# pop() call from a list object created in C-extension | |
# returns None for the first call, | |
# subscequent calls return expected values | |
import hiredis # version v0.2.0; | |
r = hiredis.Reader() | |
def get_list(): | |
# bulk array response with two items; | |
r.feed(b'*2\r\n+Item 1\r\n+Item 2\r\n') | |
return r.gets() | |
l = get_list() | |
assert isinstance(l, list) | |
assert l == [b'Item 1', b'Item 2'] | |
item = l.pop() | |
# This line fails! | |
assert item is not None and item == b'Item 2', (item, type(item)) | |
item = l.pop() | |
assert item is not None and item == b'Item 1', (item, type(item)) | |
# Another try, pop from left | |
l = get_list() | |
assert isinstance(l, list) | |
assert l == [b'Item 1', b'Item 2'] | |
item = l.pop(0) | |
# This line fails! | |
assert item is not None and item == b'Item 2', (item, type(item)) | |
item = l.pop(0) | |
assert item is not None and item == b'Item 1', (item, type(item)) | |
# Another try, pop by index | |
l = get_list() | |
assert isinstance(l, list) | |
assert l == [b'Item 1', b'Item 2'] | |
item = l.pop(1) | |
# This line fails! | |
assert item is not None and item == b'Item 2', (item, type(item)) | |
item = l.pop(0) | |
assert item is not None and item == b'Item 1', (item, type(item)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# wget -c https://bitbucket.org/pypy/pypy/downloads/pypy3-v5.7.1-linux64.tar.bz2 | |
wget -c https://bitbucket.org/pypy/pypy/downloads/pypy3-v5.8.0-linux64.tar.bz2 | |
# tar -xjf pypy3-v5.7.1-linux64.tar.bz2 | |
tar -xjf pypy3-v5.8.0-linux64.tar.bz2 | |
# ./pypy3-v5.7.1-linux64/bin/pypy3 -m venv ./tmp | |
./pypy3-v5.8.0-linux64/bin/pypy3 -m venv ./tmp | |
source ./tmp/bin/activate | |
pip install -v --force-reinstall --no-binary=:all: hiredis | |
python pypy_list_pop.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment