diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2024-02-04 19:16:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-04 19:16:43 (GMT) |
commit | 929d44e15a5667151beadb2d3a2528cd641639d6 (patch) | |
tree | 31c14abe2cafaf3ac27a22f7298f456668fed6ee /Modules/_testcapimodule.c | |
parent | da8f9fb2ea65cc2784c2400fc39ad8c800a67a42 (diff) | |
download | cpython-929d44e15a5667151beadb2d3a2528cd641639d6.zip cpython-929d44e15a5667151beadb2d3a2528cd641639d6.tar.gz cpython-929d44e15a5667151beadb2d3a2528cd641639d6.tar.bz2 |
gh-114685: PyBuffer_FillInfo() now raises on PyBUF_{READ,WRITE} (GH-114802)
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 6def680..e67de3e 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -1262,6 +1262,26 @@ make_memoryview_from_NULL_pointer(PyObject *self, PyObject *Py_UNUSED(ignored)) } static PyObject * +buffer_fill_info(PyObject *self, PyObject *args) +{ + Py_buffer info; + const char *data; + Py_ssize_t size; + int readonly; + int flags; + + if (!PyArg_ParseTuple(args, "s#ii:buffer_fill_info", + &data, &size, &readonly, &flags)) { + return NULL; + } + + if (PyBuffer_FillInfo(&info, NULL, (void *)data, size, readonly, flags) < 0) { + return NULL; + } + return PyMemoryView_FromBuffer(&info); +} + +static PyObject * test_from_contiguous(PyObject* self, PyObject *Py_UNUSED(ignored)) { int data[9] = {-1,-1,-1,-1,-1,-1,-1,-1,-1}; @@ -3314,6 +3334,7 @@ static PyMethodDef TestMethods[] = { {"eval_code_ex", eval_eval_code_ex, METH_VARARGS}, {"make_memoryview_from_NULL_pointer", make_memoryview_from_NULL_pointer, METH_NOARGS}, + {"buffer_fill_info", buffer_fill_info, METH_VARARGS}, {"crash_no_current_thread", crash_no_current_thread, METH_NOARGS}, {"test_current_tstate_matches", test_current_tstate_matches, METH_NOARGS}, {"run_in_subinterp", run_in_subinterp, METH_VARARGS}, |