Sergey
Sergey

Reputation: 21211

Can I make pylibmc work with python 3.2?

I installed some dependencies:

sudo apt-get install python3.2-dev
sudo apt-get install libmemcached-dev

And tried to:

pip install pylibmc

while in virtualenv with my python 3.2

but had this:

_pylibmcmodule.c:77:9: error: ‘PylibMC_Client’ has no member named ‘ob_type’
_pylibmcmodule.c:1812:39: error: ‘PyInt_Type’ undeclared (first use in this function)
_pylibmcmodule.c:1841:53: error: ‘PylibMC_Client’ has no member named ‘ob_type’
error: command 'gcc' failed with exit status 1

How can I fix that?
(it works with python 2.7)

Upvotes: 2

Views: 898

Answers (1)

Sergey
Sergey

Reputation: 21211

EDIT: It looks like it is working in "master" but not released yet.

I wrote some python 3 support - see my repo branch

I modified tests but still have a couple failing:

1. "test_touch" (test_client.py)  

It fails for me for both python 2 and 3. Even for unchanged code. (Looks like my memcache problem - don't know)

>       ok_(self.mc.touch(touch_test, 5))
E       SystemError: error return without exception set

2. "test_cas" (test_client.py)

Fails only for python 3. Python 2 is ok.

>           rv, cas = mc.gets(k)
E           ValueError: gets without cas behavior

It might be caused by saving Integer objects with pickle.
The responsible code is:

} else if (PyLong_Check(value_obj)) {
    serialized->flags |= PYLIBMC_FLAG_LONG;
    PyObject* tmp = PyNumber_Long(value_obj);
    store_val = PyObject_Bytes(tmp);
    Py_DECREF(tmp);

I can't use it in python 3 because PyObject_Bytes generates an error :

>       ok_(mc.set(k, 0))
E       TypeError: 'int' object is not iterable

I run tests like this:

py.test tests/test_client.py

Upvotes: 3

Related Questions