Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions python/pyarrow/src/arrow/python/udf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
}
Expand All @@ -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();
}
}
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -173,7 +177,7 @@ struct PythonUdfScalarAggregatorImpl : public ScalarUdfAggregator {
};

~PythonUdfScalarAggregatorImpl() override {
if (_Py_IsFinalizing()) {
if (Py_IsFinalizing()) {
function->detach();
}
}
Expand Down Expand Up @@ -270,7 +274,7 @@ struct PythonUdfHashAggregatorImpl : public HashUdfAggregator {
};

~PythonUdfHashAggregatorImpl() override {
if (_Py_IsFinalizing()) {
if (Py_IsFinalizing()) {
function->detach();
}
}
Expand Down