Author vstinner
Recipients vstinner
Date 2010-03-23.22:28:59
SpamBayes Score 0.00368055
Marked as misclassified No
Message-id <1269383341.97.0.71915040037.issue8215@psf.upfronthosting.co.za>
In-reply-to
Content
http://docs.python.org/py3k/c-api/arg.html contains some ambiguous (string or Unicode object) definitions: what is a string? what is an unicode object? Is it a string or not? The problem is that the documentation is for Python2: the code was changed, but not the documentation. I think that it can be replaced by (unicode objet) with lower U to be consistent with (bytes object).

---

There are two functions: getbuffer() and convertbuffer().

getbuffer(): pb=arg->ob_type->tp_as_buffer
 - if pb->bf_getbuffer is not NULL: call PyObject_GetBuffer(arg, view, PyBUF_SIMPLE) and PyBuffer_IsContiguous(view, 'C')
 - if pb->bf_getbuffer is NULL: call convertbuffer()

convertbuffer() calls PyObject_GetBuffer(arg, &view, PyBUF_SIMPLE).

---

"s#", "y", "z" formats use convertbuffer()

"s", "y*", "z*" formats uses getbuffer().

"t" format reimplements convertbuffer().

"w*" format calls PyObject_GetBuffer(arg, (Py_buffer*)p, PyBUF_WRITABLE) and PyBuffer_IsContiguous((Py_buffer*)p, 'C').

"w" and "w#" formats call PyObject_GetBuffer(arg, &view, PyBUF_SIMPLE).

I think that all these cases should be factorized in one unique function.

Is it a bug, or functions using "s#", "y", "z", "t" formats do really support discontinious buffers?

Related PEP: http://www.python.org/dev/peps/pep-3118/
History
Date User Action Args
2010-03-23 22:29:02vstinnersetrecipients: + vstinner
2010-03-23 22:29:01vstinnersetmessageid: <1269383341.97.0.71915040037.issue8215@psf.upfronthosting.co.za>
2010-03-23 22:29:00vstinnerlinkissue8215 messages
2010-03-23 22:29:00vstinnercreate