Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion python/pyarrow/src/arrow/python/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ Result<std::shared_ptr<Buffer>> PyBuffer::FromPyObject(PyObject* obj) {
}

PyBuffer::~PyBuffer() {
if (data_ != nullptr) {
// GH-38626: destructor may be called after the Python interpreter is finalized.
if (Py_IsInitialized() && data_ != nullptr) {
PyAcquireGIL lock;
PyBuffer_Release(&py_buf_);
}
Expand Down
7 changes: 5 additions & 2 deletions python/pyarrow/src/arrow/python/numpy_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ NumPyBuffer::NumPyBuffer(PyObject* ao) : Buffer(nullptr, 0) {
}

NumPyBuffer::~NumPyBuffer() {
PyAcquireGIL lock;
Py_XDECREF(arr_);
// GH-38626: destructor may be called after the Python interpreter is finalized.
if (Py_IsInitialized()) {
PyAcquireGIL lock;
Py_XDECREF(arr_);
}
}

#define TO_ARROW_TYPE_CASE(NPY_NAME, FACTORY) \
Expand Down
Loading