Commit 63a23975 authored by Stefan Behnel's avatar Stefan Behnel

Fix a reference leak for None when releasing a memoryview object.

Closes GH-3023.
parent f6f8917b
...@@ -372,6 +372,10 @@ cdef class memoryview(object): ...@@ -372,6 +372,10 @@ cdef class memoryview(object):
def __dealloc__(memoryview self): def __dealloc__(memoryview self):
if self.obj is not None: if self.obj is not None:
__Pyx_ReleaseBuffer(&self.view) __Pyx_ReleaseBuffer(&self.view)
elif (<__pyx_buffer *> &self.view).obj == Py_None:
# Undo the incref in __cinit__() above.
(<__pyx_buffer *> &self.view).obj = NULL
Py_DECREF(Py_None)
cdef int i cdef int i
global __pyx_memoryview_thread_locks_used global __pyx_memoryview_thread_locks_used
......
...@@ -698,6 +698,17 @@ def assign_temporary_to_object(object[:] mslice): ...@@ -698,6 +698,17 @@ def assign_temporary_to_object(object[:] mslice):
buf = mslice buf = mslice
buf[1] = {3-2: 2+(2*4)-2} buf[1] = {3-2: 2+(2*4)-2}
def test_pyview_of_memview(int[:] ints):
"""
>>> A = IntMockBuffer(None, [1, 2, 3])
>>> view = test_pyview_of_memview(A)
>>> len(memoryview(view))
3
"""
return ints
def test_generic_slicing(arg, indirect=False): def test_generic_slicing(arg, indirect=False):
""" """
Test simple slicing Test simple slicing
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment