Skip to content

Deprecate BufferRegion.to_string{,_argb}. #24221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/deprecations/24221-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
``BufferRegion.to_string`` and ``BufferRegion.to_string_argb``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... are deprecated. Use ``np.asarray(buffer_region)`` to get an array view on
a buffer region without making a copy; to convert that view from RGBA (the
default) to ARGB, use ``np.take(..., [2, 1, 0, 3], axis=2)``.
13 changes: 13 additions & 0 deletions src/_backend_agg_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ static void PyBufferRegion_dealloc(PyBufferRegion *self)

static PyObject *PyBufferRegion_to_string(PyBufferRegion *self, PyObject *args)
{
char const* msg =
"BufferRegion.to_string is deprecated since Matplotlib 3.7 and will "
"be removed two minor releases later; use np.asarray(region) instead.";
if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1)) {
return NULL;
}
return PyBytes_FromStringAndSize((const char *)self->x->get_data(),
self->x->get_height() * self->x->get_stride());
}
Expand Down Expand Up @@ -83,6 +89,13 @@ static PyObject *PyBufferRegion_get_extents(PyBufferRegion *self, PyObject *args

static PyObject *PyBufferRegion_to_string_argb(PyBufferRegion *self, PyObject *args)
{
char const* msg =
"BufferRegion.to_string_argb is deprecated since Matplotlib 3.7 and "
"will be removed two minor releases later; use "
"np.take(region, [2, 1, 0, 3], axis=2) instead.";
if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1)) {
return NULL;
}
PyObject *bufobj;
uint8_t *buf;

Expand Down