Skip to content

Commit 027ba10

Browse files
authored
Fix exception clauses in Buffer.fill helpers (#1381)
Use non-void return types with explicit exception clauses for Cython helpers that may raise via HANDLE_RETURN.
1 parent 09255fa commit 027ba10

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

cuda_core/cuda/core/experimental/_memory/_buffer.pyx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,15 @@ cdef inline void Buffer_close(Buffer self, stream):
383383
self._alloc_stream = None
384384

385385

386-
cdef inline void Buffer_fill_uint8(Buffer self, uint8_t value, cydriver.CUstream s):
386+
cdef inline int Buffer_fill_uint8(Buffer self, uint8_t value, cydriver.CUstream s) except? -1:
387387
with nogil:
388388
HANDLE_RETURN(cydriver.cuMemsetD8Async(<cydriver.CUdeviceptr>self._ptr, value, self._size, s))
389+
return 0
389390

390391

391-
cdef inline void Buffer_fill_from_ptr(
392+
cdef inline int Buffer_fill_from_ptr(
392393
Buffer self, const char* ptr, size_t width, cydriver.CUstream s
393-
) except *:
394+
) except? -1:
394395
cdef size_t buffer_size = self._size
395396

396397
if width == 1:
@@ -411,6 +412,7 @@ cdef inline void Buffer_fill_from_ptr(
411412
<cydriver.CUdeviceptr>self._ptr, (<uint32_t*>ptr)[0], buffer_size // 4, s))
412413
else:
413414
raise ValueError(f"value must be 1, 2, or 4 bytes, got {width}")
415+
return 0
414416

415417

416418
cdef Buffer_init_mem_attrs(Buffer self):

0 commit comments

Comments
 (0)