diff options
author | Qiming Sun <osirpt.sun@gmail.com> | 2019-09-10 02:22:12 -0700 |
---|---|---|
committer | Qiming Sun <osirpt.sun@gmail.com> | 2019-09-10 02:22:12 -0700 |
commit | 2eef5b513edd17e12e15df7f797b1ac7aed77b07 (patch) | |
tree | a7ed5775eff727aa69b7b202edefad90a520ff48 /numpy | |
parent | b42c2e3f02e6c6d0682ae148923db1b7123c5ac6 (diff) | |
download | numpy-2eef5b513edd17e12e15df7f797b1ac7aed77b07.tar.gz |
BUG: Fix _ctypes class cirular reference. (#13808)
In _ctypes class, ctypes.cast() was called twice. It causes circular reference
for _ctypes._data due to the CPython bug https://bugs.python.org/issue12836.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/_internal.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index b0ea603e1..7ef879554 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -294,8 +294,7 @@ class _ctypes(object): if ctypes: self._ctypes = ctypes # get a void pointer to the buffer, which keeps the array alive - self._data = _get_void_ptr(array) - assert self._data.value == ptr + self._data = self._ctypes.c_void_p(ptr) else: # fake a pointer-like object that holds onto the reference self._ctypes = _missing_ctypes() @@ -317,7 +316,9 @@ class _ctypes(object): The returned pointer will keep a reference to the array. """ - return self._ctypes.cast(self._data, obj) + ptr = self._ctypes.cast(self._data, obj) + ptr._arr = self._arr + return ptr def shape_as(self, obj): """ |