Skip to content

Commit 5b4751a

Browse files
slarewwjakob
authored andcommitted
Add const to buffer:request() (pybind#1890)
1 parent 8f5a8ab commit 5b4751a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/pybind11/pytypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ class buffer : public object {
13121312
public:
13131313
PYBIND11_OBJECT_DEFAULT(buffer, object, PyObject_CheckBuffer)
13141314

1315-
buffer_info request(bool writable = false) {
1315+
buffer_info request(bool writable = false) const {
13161316
int flags = PyBUF_STRIDES | PyBUF_FORMAT;
13171317
if (writable) flags |= PyBUF_WRITABLE;
13181318
Py_buffer *view = new Py_buffer();

tests/test_buffers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ TEST_SUBMODULE(buffers, m) {
7878
py::class_<Matrix>(m, "Matrix", py::buffer_protocol())
7979
.def(py::init<ssize_t, ssize_t>())
8080
/// Construct from a buffer
81-
.def(py::init([](py::buffer b) {
81+
.def(py::init([](py::buffer const b) {
8282
py::buffer_info info = b.request();
8383
if (info.format != py::format_descriptor<float>::format() || info.ndim != 2)
8484
throw std::runtime_error("Incompatible buffer format!");

0 commit comments

Comments
 (0)