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
16 changes: 10 additions & 6 deletions python/pyarrow/src/arrow/python/extension_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "arrow/python/extension_type.h"
#include "arrow/python/helpers.h"
#include "arrow/python/pyarrow.h"
#include "arrow/python/vendored/pythoncapi_compat.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/logging.h"

Expand Down Expand Up @@ -164,15 +165,18 @@ PyObject* PyExtensionType::GetInstance() const {
return nullptr;
}
ARROW_DCHECK(PyWeakref_CheckRef(type_instance_.obj()));
PyObject* inst = PyWeakref_GET_OBJECT(type_instance_.obj());
if (inst != Py_None) {
// Cached instance still alive
Py_INCREF(inst);
PyObject* inst = NULL;
int result = PyWeakref_GetRef(type_instance_.obj(), &inst);
if (result == 1) {
// Alive: inst is a new strong reference
return inst;
} else {
// Must reconstruct from serialized form
} else if (result == 0) {
// Weakref is dead, must reconstruct from serialized form
// XXX cache again?
return DeserializeExtInstance(type_class_.obj(), storage_type_, serialized_);
} else {
// -1 = exception
return nullptr;
}
}

Expand Down
Loading