Commit 69cca645 authored by Mark Florisson's avatar Mark Florisson

Delete None slices properly

parent 5da409f8
...@@ -450,8 +450,12 @@ static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW({{memviewslice_name}} *memslice, ...@@ -450,8 +450,12 @@ static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW({{memviewslice_name}} *memslice,
int last_time; int last_time;
struct {{memview_struct_name}} *memview = memslice->memview; struct {{memview_struct_name}} *memview = memslice->memview;
if (!memview || (PyObject *) memview == Py_None) if (!memview ) {
return;
} else if ((PyObject *) memview == Py_None) {
memslice->memview = NULL;
return; return;
}
if (memview->acquisition_count <= 0) if (memview->acquisition_count <= 0)
__pyx_fatalerror("Acquisition count is %d (line %d)", __pyx_fatalerror("Acquisition count is %d (line %d)",
......
...@@ -2185,3 +2185,20 @@ def test_noneslice_ext_attr(): ...@@ -2185,3 +2185,20 @@ def test_noneslice_ext_attr():
obj.m = None obj.m = None
print obj.m print obj.m
@testcase
def test_noneslice_del():
"""
>>> test_noneslice_del()
Traceback (most recent call last):
...
UnboundLocalError: local variable 'm' referenced before assignment
"""
cdef int[10] a
cdef int[:] m = a
with cython.nonecheck(True):
m = None
del m
print m
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