diff --git a/python/pyarrow/src/arrow/python/udf.cc b/python/pyarrow/src/arrow/python/udf.cc index e9b72a2592738..b6a862af8ca07 100644 --- a/pyarrow/src/arrow/python/udf.cc +++ b/pyarrow/src/arrow/python/udf.cc @@ -28,6 +28,10 @@ #include "arrow/util/checked_cast.h" #include "arrow/util/logging.h" +// Py_IsFinalizing added in Python 3.13.0a4 +#if PY_VERSION_HEX < 0x030D00A4 +#define Py_IsFinalizing() _Py_IsFinalizing() +#endif namespace arrow { using compute::ExecSpan; using compute::Grouper; @@ -47,7 +51,7 @@ struct PythonUdfKernelState : public compute::KernelState { // function needs to be destroyed at process exit // and Python may no longer be initialized. ~PythonUdfKernelState() { - if (_Py_IsFinalizing()) { + if (Py_IsFinalizing()) { function->detach(); } } @@ -64,7 +68,7 @@ struct PythonUdfKernelInit { // function needs to be destroyed at process exit // and Python may no longer be initialized. ~PythonUdfKernelInit() { - if (_Py_IsFinalizing()) { + if (Py_IsFinalizing()) { function->detach(); } } @@ -132,7 +136,7 @@ struct PythonTableUdfKernelInit { // function needs to be destroyed at process exit // and Python may no longer be initialized. ~PythonTableUdfKernelInit() { - if (_Py_IsFinalizing()) { + if (Py_IsFinalizing()) { function_maker->detach(); } } @@ -173,7 +177,7 @@ struct PythonUdfScalarAggregatorImpl : public ScalarUdfAggregator { }; ~PythonUdfScalarAggregatorImpl() override { - if (_Py_IsFinalizing()) { + if (Py_IsFinalizing()) { function->detach(); } } @@ -270,7 +274,7 @@ struct PythonUdfHashAggregatorImpl : public HashUdfAggregator { }; ~PythonUdfHashAggregatorImpl() override { - if (_Py_IsFinalizing()) { + if (Py_IsFinalizing()) { function->detach(); } }