Author: Matti Picus <matti.pi...@gmail.com> Branch: Changeset: r87886:14a562f24f66 Date: 2016-10-19 23:51 +0300 http://bitbucket.org/pypy/pypy/changeset/14a562f24f66/
Log: fix signature of PyObject_AsCharBuffer, PyDescr_NewMethod diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py --- a/pypy/module/cpyext/api.py +++ b/pypy/module/cpyext/api.py @@ -79,11 +79,16 @@ CONST_STRING = lltype.Ptr(lltype.Array(lltype.Char, hints={'nolength': True}), use_cache=False) +CONST_STRINGP = lltype.Ptr(lltype.Array(rffi.CCHARP, + hints={'nolength': True}), + use_cache=False) CONST_WSTRING = lltype.Ptr(lltype.Array(lltype.UniChar, hints={'nolength': True}), use_cache=False) assert CONST_STRING is not rffi.CCHARP assert CONST_STRING == rffi.CCHARP +assert CONST_STRINGP is not rffi.CCHARPP +assert CONST_STRINGP == rffi.CCHARPP assert CONST_WSTRING is not rffi.CWCHARP assert CONST_WSTRING == rffi.CWCHARP @@ -1004,6 +1009,8 @@ for i, argtype in enumerate(func.argtypes): if argtype is CONST_STRING: arg = 'const char *@' + elif argtype is CONST_STRINGP: + arg = 'const char **@' elif argtype is CONST_WSTRING: arg = 'const wchar_t *@' else: diff --git a/pypy/module/cpyext/methodobject.py b/pypy/module/cpyext/methodobject.py --- a/pypy/module/cpyext/methodobject.py +++ b/pypy/module/cpyext/methodobject.py @@ -311,7 +311,7 @@ def PyClassMethod_New(space, w_func): return space.wrap(ClassMethod(w_func)) -@cpython_api([PyObject, lltype.Ptr(PyMethodDef)], PyObject) +@cpython_api([PyTypeObjectPtr, lltype.Ptr(PyMethodDef)], PyObject) def PyDescr_NewMethod(space, w_type, method): return space.wrap(W_PyCMethodObject(space, method, w_type)) diff --git a/pypy/module/cpyext/object.py b/pypy/module/cpyext/object.py --- a/pypy/module/cpyext/object.py +++ b/pypy/module/cpyext/object.py @@ -3,7 +3,7 @@ cpython_api, generic_cpy_call, CANNOT_FAIL, Py_ssize_t, Py_ssize_tP, PyVarObject, Py_buffer, size_t, Py_TPFLAGS_HEAPTYPE, Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, - Py_GE, CONST_STRING, FILEP, fwrite) + Py_GE, CONST_STRING, CONST_STRINGP, FILEP, fwrite) from pypy.module.cpyext.pyobject import ( PyObject, PyObjectP, create_ref, from_ref, Py_IncRef, Py_DecRef, get_typedescr, _Py_NewReference) @@ -429,7 +429,7 @@ is active then NULL is returned but PyErr_Occurred() will return false.""" return space.call_function(space.builtin.get('dir'), w_o) -@cpython_api([PyObject, rffi.CCHARPP, Py_ssize_tP], rffi.INT_real, error=-1) +@cpython_api([PyObject, CONST_STRINGP, Py_ssize_tP], rffi.INT_real, error=-1) def PyObject_AsCharBuffer(space, obj, bufferp, sizep): """Returns a pointer to a read-only memory location usable as character-based input. The obj argument must support the single-segment diff --git a/pypy/module/cpyext/test/test_abstract.py b/pypy/module/cpyext/test/test_abstract.py --- a/pypy/module/cpyext/test/test_abstract.py +++ b/pypy/module/cpyext/test/test_abstract.py @@ -10,7 +10,7 @@ """ char *ptr; Py_ssize_t size; - if (PyObject_AsCharBuffer(args, &ptr, &size) < 0) + if (PyObject_AsCharBuffer(args, (const char **)&ptr, &size) < 0) return NULL; return PyString_FromStringAndSize(ptr, size); """), diff --git a/pypy/module/cpyext/test/test_bufferobject.py b/pypy/module/cpyext/test/test_bufferobject.py --- a/pypy/module/cpyext/test/test_bufferobject.py +++ b/pypy/module/cpyext/test/test_bufferobject.py @@ -25,7 +25,7 @@ """ char *ptr; Py_ssize_t size; - if (PyObject_AsCharBuffer(args, &ptr, &size) < 0) + if (PyObject_AsCharBuffer(args, (const char **)&ptr, &size) < 0) return NULL; return PyString_FromStringAndSize(ptr, size); """) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit