Ian M. Hoffman <hoffman.ia...@gmail.com> added the comment:

You are correct.

After further review, I found an older ctypes issue #12836 which was then 
enshrined in a workaround in the numpy.ndarray.ctypes interface to vanilla 
ctypes.

https://numpy.org/doc/stable/reference/generated/numpy.ndarray.ctypes.html

Numpy ctypes has both a `data` method for which "a reference will not be kept 
to the array" and a `data_as` method which has the desired behavior: "The 
returned pointer will keep a reference to the array."

So, we've all got our workarounds. What remains is whether/how to implement a 
check in Python for the dangling pointer. I have no advice on that, except that 
it is desirable to avoid the fault crash, no matter who is to blame.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41883>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to