Skip to content

Commit 072f67d

Browse files
committed
Enhance _is_pycapsule function to recognize both "PyCapsule" and "capsule" types
1 parent 86e8caa commit 072f67d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

python/datafusion/user_defined.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ def __datafusion_scalar_udf__(self) -> object: ... # noqa: D105
101101

102102
def _is_pycapsule(value: object) -> TypeGuard[_PyCapsule]:
103103
"""Return ``True`` when ``value`` is a CPython ``PyCapsule``."""
104-
return value.__class__.__name__ == "PyCapsule"
104+
105+
type_name = type(value).__name__
106+
# CPython exposes capsule objects with the type name "capsule"
107+
return type_name in {"PyCapsule", "capsule"}
105108

106109

107110
class ScalarUDF:

0 commit comments

Comments
 (0)