summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2023-06-02 01:12:40 (GMT)
committerGitHub <noreply@github.com>2023-06-02 01:12:40 (GMT)
commit37498fc95012ba8e147db646b841bc3d36ddf4af (patch)
treecd71e0d73e0eb7e013f12862593b909cd739014d /Doc/whatsnew
parentef300937c2a1b3ebe19c2835f3b46585825c1e1f (diff)
downloadcpython-37498fc95012ba8e147db646b841bc3d36ddf4af.zip
cpython-37498fc95012ba8e147db646b841bc3d36ddf4af.tar.gz
cpython-37498fc95012ba8e147db646b841bc3d36ddf4af.tar.bz2
gh-85275: Remove old buffer APIs (#105137)
They are now abi-only. Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/3.13.rst36
1 files changed, 36 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index e4b6e3b..04ac34e 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -395,6 +395,42 @@ Removed
(Contributed by Victor Stinner in :gh:`105107`.)
+* Remove old buffer protocols deprecated in Python 3.0. Use :ref:`bufferobjects` instead.
+
+ * :c:func:`!PyObject_CheckReadBuffer`: Use :c:func:`PyObject_CheckBuffer` to
+ test if the object supports the buffer protocol.
+ Note that :c:func:`PyObject_CheckBuffer` doesn't guarantee that
+ :c:func:`PyObject_GetBuffer` will succeed.
+ To test if the object is actually readable, see the next example
+ of :c:func:`PyObject_GetBuffer`.
+
+ * :c:func:`!PyObject_AsCharBuffer`, :c:func:`!PyObject_AsReadBuffer`:
+ :c:func:`PyObject_GetBuffer` and :c:func:`PyBuffer_Release` instead:
+
+ .. code-block:: c
+
+ Py_buffer view;
+ if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) < 0) {
+ return NULL;
+ }
+ // Use `view.buf` and `view.len` to read from the buffer.
+ // You may need to cast buf as `(const char*)view.buf`.
+ PyBuffer_Release(&view);
+
+ * :c:func:`!PyObject_AsWriteBuffer`: Use
+ :c:func:`PyObject_GetBuffer` and :c:func:`PyBuffer_Release` instead:
+
+ .. code-block:: c
+
+ Py_buffer view;
+ if (PyObject_GetBuffer(obj, &view, PyBUF_WRITABLE) < 0) {
+ return NULL;
+ }
+ // Use `view.buf` and `view.len` to write to the buffer.
+ PyBuffer_Release(&view);
+
+ (Contributed by Inada Naoki in :gh:`85275`.)
+
* Remove the following old functions to configure the Python initialization,
deprecated in Python 3.11: