2013-04-12 61 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

相關問題