paultiq commented on issue #47823:
URL: https://github.com/apache/arrow/issues/47823#issuecomment-3480202389
That works too!
In that case, it'd be:
```diff
+ #include "arrow/python/vendored/pythoncapi_compat.h"
...
@@ -164,10 +165,13 @@ 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) {
+ PyObject* inst = NULL;
+ int result = PyWeakref_GetRef(type_instance_.obj(), &inst);
+ if (result < 0) {
+ // Error
+ return nullptr;
+ } else if (result > 0) {
// Cached instance still alive
- Py_INCREF(inst);
return inst;
} else {
// Must reconstruct from serialized form
// XXX cache again?
return DeserializeExtInstance(type_class_.obj(), storage_type_,
serialized_);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]