Commit de9757c2 authored by Mark Florisson's avatar Mark Florisson

Fix incref in test + have_gil arg to xdec_memview on err/return

parent b3d97a43
...@@ -1509,8 +1509,6 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1509,8 +1509,6 @@ class FuncDefNode(StatNode, BlockNode):
for entry in lenv.buffer_entries: for entry in lenv.buffer_entries:
Buffer.put_release_buffer_code(code, entry) Buffer.put_release_buffer_code(code, entry)
#code.putln("%s = 0;" % entry.cname) #code.putln("%s = 0;" % entry.cname)
#for entry in memslice_entries:
# code.put_xdecref_memoryviewslice(entry.cname)
code.putln("__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}") code.putln("__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}")
if self.return_type.is_memoryviewslice: if self.return_type.is_memoryviewslice:
...@@ -1597,8 +1595,8 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1597,8 +1595,8 @@ class FuncDefNode(StatNode, BlockNode):
continue continue
if entry.type.is_memoryviewslice: if entry.type.is_memoryviewslice:
#code.put_xdecref("%s.memview" % entry.cname, cython_memoryview_ptr_type) code.put_xdecref_memoryviewslice(entry.cname,
code.put_xdecref_memoryviewslice(entry.cname) have_gil=not lenv.nogil)
elif entry.type.is_pyobject: elif entry.type.is_pyobject:
code.put_var_decref(entry) code.put_var_decref(entry)
...@@ -1609,8 +1607,8 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1609,8 +1607,8 @@ class FuncDefNode(StatNode, BlockNode):
if (acquire_gil or entry.assignments) and not entry.in_closure: if (acquire_gil or entry.assignments) and not entry.in_closure:
code.put_var_decref(entry) code.put_var_decref(entry)
if entry.type.is_memoryviewslice: if entry.type.is_memoryviewslice:
code.put_xdecref_memoryviewslice(entry.cname) code.put_xdecref_memoryviewslice(entry.cname,
#code.put_decref("%s.memview" % entry.cname, cython_memoryview_ptr_type) have_gil=not lenv.nogil)
if self.needs_closure: if self.needs_closure:
code.put_decref(Naming.cur_scope_cname, lenv.scope_class.type) code.put_decref(Naming.cur_scope_cname, lenv.scope_class.type)
...@@ -1654,7 +1652,7 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1654,7 +1652,7 @@ class FuncDefNode(StatNode, BlockNode):
# ----- Go back and insert temp variable declarations # ----- Go back and insert temp variable declarations
tempvardecl_code.put_temp_declarations(code.funcstate) tempvardecl_code.put_temp_declarations(code.funcstate)
if code.funcstate.should_declare_error_indicator: if code.funcstate.should_declare_error_indicator:
# Initialize these variables to shut up compiler warnings # Initialize these variables to silence compiler warnings
tempvardecl_code.putln("int %s = 0;" % Naming.lineno_cname) tempvardecl_code.putln("int %s = 0;" % Naming.lineno_cname)
tempvardecl_code.putln("const char *%s = NULL;" % tempvardecl_code.putln("const char *%s = NULL;" %
Naming.filename_cname) Naming.filename_cname)
...@@ -4347,8 +4345,6 @@ class ReturnStatNode(StatNode): ...@@ -4347,8 +4345,6 @@ class ReturnStatNode(StatNode):
if self.return_type.is_pyobject: if self.return_type.is_pyobject:
code.put_xdecref(Naming.retval_cname, code.put_xdecref(Naming.retval_cname,
self.return_type) self.return_type)
#elif self.return_type.is_memoryviewslice:
# code.put_xdecref_memoryviewslice(Naming.retval_cname)
if self.value: if self.value:
self.value.generate_evaluation_code(code) self.value.generate_evaluation_code(code)
...@@ -4360,7 +4356,7 @@ class ReturnStatNode(StatNode): ...@@ -4360,7 +4356,7 @@ class ReturnStatNode(StatNode):
lhs_pos=self.value.pos, lhs_pos=self.value.pos,
rhs=self.value, rhs=self.value,
code=code, code=code,
incref_rhs=value.is_name, incref_rhs=self.value.is_name,
have_gil=self.in_nogil_context) have_gil=self.in_nogil_context)
else: else:
self.value.make_owned_reference(code) self.value.make_owned_reference(code)
......
...@@ -1095,7 +1095,7 @@ class UniqueObject(object): ...@@ -1095,7 +1095,7 @@ class UniqueObject(object):
return self.value return self.value
objs = [[UniqueObject("spam")], [UniqueObject("ham")], [UniqueObject("eggs")]] objs = [[UniqueObject("spam")], [UniqueObject("ham")], [UniqueObject("eggs")]]
addref(*objs) addref(*[obj for L in objs for obj in L])
cdef cdef_function(int[:] buf1, object[::view.indirect, :] buf2 = ObjectMockBuffer(None, objs)): cdef cdef_function(int[:] buf1, object[::view.indirect, :] buf2 = ObjectMockBuffer(None, objs)):
print 'cdef called' print 'cdef called'
print buf1[6], buf2[1, 0] print buf1[6], buf2[1, 0]
...@@ -1115,11 +1115,11 @@ def test_cdef_function(o1, o2=None): ...@@ -1115,11 +1115,11 @@ def test_cdef_function(o1, o2=None):
6 eggs 6 eggs
released A released A
>> L = [[x] for x in range(25)] >>> L = [[x] for x in range(25)]
>> addref(*L) >>> addref(*[obj for mylist in L for obj in mylist])
>> B = ObjectMockBuffer("B", L, shape=(5, 5)) >>> B = ObjectMockBuffer("B", L, shape=(5, 5))
>> test_cdef_function(A, B) >>> test_cdef_function(A, B)
acquired A acquired A
cdef called cdef called
6 eggs 6 eggs
...@@ -1143,7 +1143,7 @@ def test_cdef_function(o1, o2=None): ...@@ -1143,7 +1143,7 @@ def test_cdef_function(o1, o2=None):
cdef int[:] global_A = IntMockBuffer("Global_A", range(10)) cdef int[:] global_A = IntMockBuffer("Global_A", range(10))
addref(*objs) addref(*[obj for L in objs for obj in L])
cdef object[::view.indirect, :] global_B = ObjectMockBuffer(None, objs) cdef object[::view.indirect, :] global_B = ObjectMockBuffer(None, objs)
cdef cdef_function2(int[:] buf1, object[::view.indirect, :] buf2 = global_B): cdef cdef_function2(int[:] buf1, object[::view.indirect, :] buf2 = global_B):
......
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