|
69 | 69 | "BrokenIter", |
70 | 70 | "in_systemd_nspawn_sync_suppressed", |
71 | 71 | "run_no_yield_async_fn", "run_yielding_async_fn", "async_yield", |
72 | | - "reset_code", "on_github_actions", "ctypes_py_buffer", |
| 72 | + "reset_code", "on_github_actions" |
73 | 73 | ] |
74 | 74 |
|
75 | 75 |
|
@@ -3272,47 +3272,3 @@ def linked_to_musl(): |
3272 | 3272 | return _linked_to_musl |
3273 | 3273 | _linked_to_musl = tuple(map(int, version.split('.'))) |
3274 | 3274 | return _linked_to_musl |
3275 | | - |
3276 | | - |
3277 | | -try: |
3278 | | - import ctypes |
3279 | | - |
3280 | | - class _py_buffer(ctypes.Structure): |
3281 | | - _fields_ = [ |
3282 | | - ("buf", ctypes.c_void_p), |
3283 | | - ("obj", ctypes.py_object), |
3284 | | - ("len", ctypes.c_ssize_t), |
3285 | | - ("itemsize", ctypes.c_ssize_t), |
3286 | | - ("readonly", ctypes.c_int), |
3287 | | - ("ndim", ctypes.c_int), |
3288 | | - ("format", ctypes.c_char_p), |
3289 | | - ("shape", ctypes.POINTER(ctypes.c_ssize_t)), |
3290 | | - ("strides", ctypes.POINTER(ctypes.c_ssize_t)), |
3291 | | - ("suboffsets", ctypes.POINTER(ctypes.c_ssize_t)), |
3292 | | - ("internal", ctypes.c_void_p), |
3293 | | - ] |
3294 | | -except ImportError: |
3295 | | - _py_buffer = None |
3296 | | - |
3297 | | - |
3298 | | -@contextlib.contextmanager |
3299 | | -def ctypes_py_buffer(ob, flags=inspect.BufferFlags.SIMPLE): |
3300 | | - """ |
3301 | | - Safely acquire a `Py_buffer` as a ctypes struct. |
3302 | | -
|
3303 | | - `ob` must implement the buffer protocol, and the retrieved buffer is |
3304 | | - released on exit of the context manager. |
3305 | | -
|
3306 | | - Skips any test using it if `ctypes` is unavailable. |
3307 | | - """ |
3308 | | - from .import_helper import import_module |
3309 | | - |
3310 | | - ctypes = import_module("ctypes") |
3311 | | - buf = _py_buffer() |
3312 | | - ctypes.pythonapi.PyObject_GetBuffer(ctypes.py_object(ob), |
3313 | | - ctypes.byref(buf), |
3314 | | - ctypes.c_int(flags)) |
3315 | | - try: |
3316 | | - yield buf |
3317 | | - finally: |
3318 | | - ctypes.pythonapi.PyBuffer_Release(ctypes.byref(buf)) |
0 commit comments