Skip to content

Commit

Permalink
Mark dlpack tensor deleter as noexcept to match PyCapsule_Destructor …
Browse files Browse the repository at this point in the history
…signature. (#12921)

This is a fix for a Cython problem that appears when building with Cython 3.0.0 beta 1. There are a bunch of warnings I'd like to fix as well, but this is the only hard error. The fix is to use `noexcept` in the deleter definition.

```
Error compiling Cython file:
------------------------------------------------------------
...
        )
    return pycapsule.PyCapsule_New(
        dlpack_tensor,
        'dltensor',
        dlmanaged_tensor_pycapsule_deleter
        ^
------------------------------------------------------------
/home/bdice/code/cudf/python/cudf/cudf/_lib/interop.pyx:69:8: Cannot assign type 'void (object) except *' to 'PyCapsule_Destructor'
```

Authors:
  - Bradley Dice (https://github.com/bdice)
  - Ashwin Srinath (https://github.com/shwina)

Approvers:
  - https://github.com/jakirkham
  - Lawrence Mitchell (https://github.com/wence-)
  - Ashwin Srinath (https://github.com/shwina)

URL: #12921
  • Loading branch information
bdice authored Mar 15, 2023
1 parent 3c72eb0 commit a33e368
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/cudf/cudf/_lib/interop.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2022, NVIDIA CORPORATION.
# Copyright (c) 2020-2023, NVIDIA CORPORATION.

from cpython cimport pycapsule
from libcpp.memory cimport shared_ptr, unique_ptr
Expand Down Expand Up @@ -70,7 +70,7 @@ def to_dlpack(list source_columns):
)


cdef void dlmanaged_tensor_pycapsule_deleter(object pycap_obj):
cdef void dlmanaged_tensor_pycapsule_deleter(object pycap_obj) noexcept:
cdef DLManagedTensor* dlpack_tensor = <DLManagedTensor*>0
try:
dlpack_tensor = <DLManagedTensor*>pycapsule.PyCapsule_GetPointer(
Expand Down

0 comments on commit a33e368

Please sign in to comment.