Fix #444 (utility code not pulled in in corner case)
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Mon, 2 Nov 2009 19:23:01 +0000 (20:23 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Mon, 2 Nov 2009 19:23:01 +0000 (20:23 +0100)
Cython/Compiler/Buffer.py
Cython/Compiler/Nodes.py
tests/compile/bufaccess_noassignT444.pyx [new file with mode: 0644]

index b297ad152dae69c284025c1b6e1dae2902aef326..e807d4281a51b0c96b82009ecb50a05343b03a52 100644 (file)
@@ -245,8 +245,9 @@ def put_acquire_arg_buffer(entry, code, pos):
     # need to care about the buffer then.
     put_unpack_buffer_aux_into_scope(buffer_aux, entry.type.mode, code)
 
-def get_release_buffer_code(entry):
-    return "__Pyx_SafeReleaseBuffer(&%s)" % entry.buffer_aux.buffer_info_var.cname
+def put_release_buffer_code(code, entry):
+    code.globalstate.use_utility_code(acquire_utility_code)
+    code.putln("__Pyx_SafeReleaseBuffer(&%s);" % entry.buffer_aux.buffer_info_var.cname)
 
 def get_getbuffer_call(code, obj_cname, buffer_aux, buffer_type):
     ndim = buffer_type.ndim
index 8b37eb860ca278de894e7572057d113196f30558..b192eefcb404ba9b4c5d694b153be2ba18162b65 100644 (file)
@@ -1142,8 +1142,8 @@ class FuncDefNode(StatNode, BlockNode):
                 code.globalstate.use_utility_code(restore_exception_utility_code)
                 code.putln("{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;")
                 code.putln("__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);")
-                for entry in lenv.buffer_entries:
-                    code.putln("%s;" % Buffer.get_release_buffer_code(entry))
+                for entry in lenv.buffer_entries:                    
+                    Buffer.put_release_buffer_code(code, entry)
                     #code.putln("%s = 0;" % entry.cname)
                 code.putln("__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}")
 
@@ -1185,7 +1185,7 @@ class FuncDefNode(StatNode, BlockNode):
         code.put_label(code.return_label)
         for entry in lenv.buffer_entries:
             if entry.used:
-                code.putln("%s;" % Buffer.get_release_buffer_code(entry))
+                Buffer.put_release_buffer_code(code, entry)
         if is_getbuffer_slot:
             self.getbuffer_normal_cleanup(code)
         # ----- Return cleanup for both error and no-error return
diff --git a/tests/compile/bufaccess_noassignT444.pyx b/tests/compile/bufaccess_noassignT444.pyx
new file mode 100644 (file)
index 0000000..061a4e2
--- /dev/null
@@ -0,0 +1,4 @@
+
+def test():
+     cdef object[int] not_assigned_to
+     not_assigned_to[2] = 3