Skip to content

Commit

Permalink
apacheGH-41475: [Python] Build with Python 3.13 (apache#42034)
Browse files Browse the repository at this point in the history
### Rationale for this change

The private function `_Py_IsFinalizing` renamed to `Py_IsFinalizing` in Python 3.13.0a1.  Without this change pyarrow will not compile with this version of Python or higher.

### What changes are included in this PR?

add a version-gated `#define` to handle the change.

### Are these changes tested?

Local build succeeds. 

### Are there any user-facing changes?

no

* GitHub Issue: apache#41475

Lead-authored-by: Thomas A Caswell <tcaswell@gmail.com>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
  • Loading branch information
3 people authored and zanmato1984 committed Jul 9, 2024
1 parent 2a75ef9 commit feaa254
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit feaa254

Please sign in to comment.