2013-04-12 58 views
2

我安装了一些依赖:我可以用python 3.2制作pylibmc吗?

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

并试图:

pip install pylibmc 

而在virtualenv中有我的Python 3.2

,但有这样的:

_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 

我怎样才能修复?
(它的工作原理与Python 2.7)

+0

我猜你需要开始移植,请参阅http://python3porting.com/cextensions.html –

+0

@MartijnPieters,如果你想要测试它=)https://github.com/pashinin/pylibmc/tree/python3-test – Sergey

回答

3

编辑:它看起来就像是工作在“大师”,但尚未公布。

我写了一些Python 3支持 - see my repo branch

我修改了测试,但仍然有一对夫妇的失败:

1. "test_touch" (test_client.py) 

它失败对我来说既Python 2和3,即使是不变的代码。 (貌似我的内存缓存的问题 - 不知道)

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

2. "test_cas" (test_client.py) 

仅供巨蟒3. Python 2里就可以了失败。

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

这可能是由保存整数对象与pickle引起的。
该负责代码:

} 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); 

在Python 3,我不能使用它,因为PyObject_Bytesgenerates an error

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

我运行测试是这样的:

py.test tests/test_client.py 
+0

非常酷!下一步就是让测试在Python 2和Python 3上都能正常工作,这样您就可以根据现有的测试套件来验证您的工作了! –

+0

@MartijnPieters,几乎做到了...... – Sergey

相关问题