Skip to content

gh-112015: Implement ctypes.memoryview_at() #112018

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 25 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
236657b
Implement `ctypes.buffer_at()`
rianhunter Nov 13, 2023
55d7690
Fix typo
rianhunter Nov 13, 2023
00e3c23
Apply suggestions from code review
rianhunter Jan 18, 2024
df0f992
Make size argument a Py_ssize_t, per @serhiy-storchaka suggestion
rianhunter Jan 19, 2024
eaa2d13
Add what's new entry
rianhunter Jan 19, 2024
db3a26a
Rename buffer_at to memoryview_at
rianhunter Jan 19, 2024
d7e2f25
Make mutable objects the default
rianhunter Jan 19, 2024
097a41c
Add test for ctypes.memoryview_at
rianhunter Jan 19, 2024
4fe9b44
Merge in the main branch; move What's New entry
encukou Sep 18, 2024
e2c2609
TMP
encukou Sep 18, 2024
d39bb42
Merge in the main branch
encukou Nov 29, 2024
3a6b559
Revert to calling through `ctypes` to get `c_void_p` conversion seman…
encukou Nov 29, 2024
375081a
Test read-only memoryview
encukou Nov 29, 2024
b9e8572
Use c_ssize_t for the size
encukou Nov 29, 2024
1a33fe3
Test size overflow
encukou Nov 29, 2024
0198c89
Doc fixups. Don't imply that *readonly* makes the memory immutable.
encukou Nov 29, 2024
6b0a8ae
Fixups
encukou Nov 29, 2024
e4af54f
Merge branch 'main' into ctypes-buffer-at
encukou Dec 12, 2024
5600cef
Apply suggestions from code review
encukou Dec 19, 2024
c3c9e17
Avoid extra variable
encukou Dec 19, 2024
d1ca15d
Merge in the main branch
encukou Dec 19, 2024
d41a201
Remove unneeded line
encukou Dec 20, 2024
f3b1987
Merge in the main branch
encukou Dec 20, 2024
82a6659
Merge in the main branch
encukou Jan 2, 2025
400a62d
Remove unneeded line
encukou Jan 2, 2025
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
Prev Previous commit
Next Next commit
Make size argument a Py_ssize_t, per @serhiy-storchaka suggestion
  • Loading branch information
rianhunter committed Jan 19, 2024
commit df0f992fbbfd7911e7eb8eca97dc8abadc6ac441
2 changes: 1 addition & 1 deletion Lib/ctypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def wstring_at(ptr, size=-1):

from _ctypes import _buffer_at_addr

_buffer_at = PYFUNCTYPE(py_object, c_void_p, c_int, c_int)(_buffer_at_addr)
_buffer_at = PYFUNCTYPE(py_object, c_void_p, c_ssize_t, c_int)(_buffer_at_addr)
def buffer_at(ptr, size, allow_write=False):
"""buffer_at(addr, size[, allow_write]) -> memoryview

Expand Down
4 changes: 2 additions & 2 deletions Modules/_ctypes/_ctypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -5643,9 +5643,9 @@ wstring_at(const wchar_t *ptr, int size)
}

static PyObject *
buffer_at(char *ptr, int size, int allow_write)
buffer_at(char *ptr, Py_ssize_t size, int allow_write)
{
if (PySys_Audit("ctypes.buffer_at", "nii", (Py_ssize_t)ptr, size,
if (PySys_Audit("ctypes.buffer_at", "nni", (Py_ssize_t)ptr, size,
allow_write) < 0) {
return NULL;
}
Expand Down