Commit 8164bb31 authored by Robert Bradshaw's avatar Robert Bradshaw

Merge pull request #177 from strohel/propagate-error-memoryview

Fix error propagation from memoryview-returning functions
parents d06c8958 ec2c8d97
......@@ -1770,7 +1770,7 @@ class FuncDefNode(StatNode, BlockNode):
# If we are using the non-error cleanup section we should
# jump past it if we have an error. The if-test below determine
# whether this section is used.
if buffers_present or is_getbuffer_slot:
if buffers_present or is_getbuffer_slot or self.return_type.is_memoryviewslice:
code.put_goto(code.return_from_error_cleanup_label)
# ----- Non-error return cleanup
......
# mode: run
cdef double[:] foo(int i):
if i == 1:
raise AttributeError('dummy')
if i == 2:
raise RuntimeError('dummy')
if i == 3:
raise ValueError('dummy')
if i == 4:
raise TypeError('dummy')
def propagate(i):
'''
>>> propagate(0)
TypeError('Memoryview return value is not initialized',)
>>> propagate(1)
AttributeError('dummy',)
>>> propagate(2)
RuntimeError('dummy',)
>>> propagate(3)
ValueError('dummy',)
>>> propagate(4)
TypeError('dummy',)
'''
try:
foo(i)
except Exception as e:
print repr(e)
else:
print 'Exception sublass not raised'
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