Commit 8b1a4177 authored by Mark Florisson's avatar Mark Florisson

cython.parallel: Use restore exception utility code when code.error_label is used

parent 85d9b64b
......@@ -6458,6 +6458,7 @@ class ParallelStatNode(StatNode, ParallelNode):
code.put_goto(code.return_label)
if self.error_label_used:
code.globalstate.use_utility_code(restore_exception_utility_code)
code.putln(" case 4:")
self.restore_parallel_exception(code)
code.put_goto(code.error_label)
......@@ -6539,7 +6540,7 @@ class ParallelRangeNode(ParallelStatNode):
is_prange = True
nogil = False
nogil = None
schedule = None
num_threads = None
......@@ -6576,6 +6577,10 @@ class ParallelRangeNode(ParallelStatNode):
(self.schedule,))
def analyse_expressions(self, env):
if self.nogil:
was_nogil = env.nogil
env.nogil = True
if self.target is None:
error(self.pos, "prange() can only be used as part of a for loop")
return
......@@ -6627,6 +6632,9 @@ class ParallelRangeNode(ParallelStatNode):
super(ParallelRangeNode, self).analyse_expressions(env)
if self.nogil:
env.nogil = was_nogil
def nogil_check(self, env):
names = 'start', 'stop', 'step', 'target'
nodes = self.start, self.stop, self.step, self.target
......
# mode: error
from cython.parallel import *
def psum(int n):
cdef double sum
cdef int i
cdef double x,step,t1,t2
sum=0
step=1.0/n
for i in prange(n,nogil=True):
x = (i)*step
sum+=4.0/(1.0+x*x)
return sum*step
_ERRORS = u"""
e_cython_parallel_nogil_env.pyx:12:15: Pythonic division not allowed without gil, consider using cython.cdivision(True)
"""
......@@ -705,3 +705,18 @@ def outer_parallel_section():
for i in prange(10, nogil=True):
sum += inner_parallel_section()
return sum
cdef int nogil_cdef_except_clause() nogil except 0:
return 1
cdef void nogil_cdef_except_star() nogil except *:
pass
def test_nogil_cdef_except_clause():
"""
>>> test_nogil_cdef_except_clause()
"""
cdef int i
for i in prange(10, nogil=True):
nogil_cdef_except_clause()
nogil_cdef_except_star()
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