Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
5b4751af
Commit
5b4751af
authored
Aug 27, 2019
by
Stephen Larew
Committed by
Wenzel Jakob
Aug 27, 2019
Browse files
Add const to buffer:request() (#1890)
parent
8f5a8ab4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
include/pybind11/pytypes.h
include/pybind11/pytypes.h
+1
-1
tests/test_buffers.cpp
tests/test_buffers.cpp
+1
-1
No files found.
include/pybind11/pytypes.h
View file @
5b4751af
...
...
@@ -1312,7 +1312,7 @@ class buffer : public object {
public:
PYBIND11_OBJECT_DEFAULT
(
buffer
,
object
,
PyObject_CheckBuffer
)
buffer_info
request
(
bool
writable
=
false
)
{
buffer_info
request
(
bool
writable
=
false
)
const
{
int
flags
=
PyBUF_STRIDES
|
PyBUF_FORMAT
;
if
(
writable
)
flags
|=
PyBUF_WRITABLE
;
Py_buffer
*
view
=
new
Py_buffer
();
...
...
tests/test_buffers.cpp
View file @
5b4751af
...
...
@@ -78,7 +78,7 @@ TEST_SUBMODULE(buffers, m) {
py
::
class_
<
Matrix
>
(
m
,
"Matrix"
,
py
::
buffer_protocol
())
.
def
(
py
::
init
<
ssize_t
,
ssize_t
>
())
/// Construct from a buffer
.
def
(
py
::
init
([](
py
::
buffer
b
)
{
.
def
(
py
::
init
([](
py
::
buffer
const
b
)
{
py
::
buffer_info
info
=
b
.
request
();
if
(
info
.
format
!=
py
::
format_descriptor
<
float
>::
format
()
||
info
.
ndim
!=
2
)
throw
std
::
runtime_error
(
"Incompatible buffer format!"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment