PyObject_AsReadBuffer移植

时间:2014-02-20 09:07:18

标签: python c++ porting

众所周知,int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len)已从v2.5更改,后者使用int*类型buffer_len。 如果我希望程序从v2.4移植到v2.7,如果我只是将int替换为Py_ssize_t,是否有任何问题?

样品: V2.4

    int bufferLength = 0;
    const void* buffer = NULL;
    PyObject_AsReadBuffer(pyObj, &buffer, &buffer_len);  //pyObj is assigned in somewhere

V2.7

    Py_ssize_t bufferLength = 0;
    const void* buffer = NULL;
    PyObject_AsReadBuffer(pyObj, &buffer, &buffer_len);  //pyObj is assigned in somewhere

我在哪里可以找到此功能的源代码?

1 个答案:

答案 0 :(得分:0)

没问题,只需将int替换为Py_ssize_t,就可以了。