source: python/trunk/Doc/c-api/objbuffer.rst

Last change on this file was 391, checked in by dmik, 11 years ago

python: Merge vendor 2.7.6 to trunk.

  • Property svn:eol-style set to native
File size: 2.5 KB
RevLine 
[2]1.. highlightlang:: c
2
3.. _abstract-buffer:
4
[391]5
[2]6Old Buffer Protocol
7===================
8
9This section describes the legacy buffer protocol, which has been introduced
10in Python 1.6. It is still supported but deprecated in the Python 2.x series.
[391]11Python 3 introduces a new buffer protocol which fixes weaknesses and
[2]12shortcomings of the protocol, and has been backported to Python 2.6. See
13:ref:`bufferobjects` for more information.
14
15
[391]16.. c:function:: int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len)
[2]17
18 Returns a pointer to a read-only memory location usable as character-based
19 input. The *obj* argument must support the single-segment character buffer
20 interface. On success, returns ``0``, sets *buffer* to the memory location
21 and *buffer_len* to the buffer length. Returns ``-1`` and sets a
22 :exc:`TypeError` on error.
23
24 .. versionadded:: 1.6
25
26 .. versionchanged:: 2.5
[391]27 This function used an :c:type:`int *` type for *buffer_len*. This might
[2]28 require changes in your code for properly supporting 64-bit systems.
29
30
[391]31.. c:function:: int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len)
[2]32
33 Returns a pointer to a read-only memory location containing arbitrary data.
34 The *obj* argument must support the single-segment readable buffer
35 interface. On success, returns ``0``, sets *buffer* to the memory location
36 and *buffer_len* to the buffer length. Returns ``-1`` and sets a
37 :exc:`TypeError` on error.
38
39 .. versionadded:: 1.6
40
41 .. versionchanged:: 2.5
[391]42 This function used an :c:type:`int *` type for *buffer_len*. This might
[2]43 require changes in your code for properly supporting 64-bit systems.
44
45
[391]46.. c:function:: int PyObject_CheckReadBuffer(PyObject *o)
[2]47
48 Returns ``1`` if *o* supports the single-segment readable buffer interface.
49 Otherwise returns ``0``.
50
51 .. versionadded:: 2.2
52
53
[391]54.. c:function:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len)
[2]55
56 Returns a pointer to a writeable memory location. The *obj* argument must
57 support the single-segment, character buffer interface. On success,
58 returns ``0``, sets *buffer* to the memory location and *buffer_len* to the
59 buffer length. Returns ``-1`` and sets a :exc:`TypeError` on error.
60
61 .. versionadded:: 1.6
62
63 .. versionchanged:: 2.5
[391]64 This function used an :c:type:`int *` type for *buffer_len*. This might
[2]65 require changes in your code for properly supporting 64-bit systems.
66
Note: See TracBrowser for help on using the repository browser.