Commit 95bf3e76 authored by Stefan Behnel's avatar Stefan Behnel

Merge branch '0.29.x'

parents 9470dab5 61505ce4
......@@ -112,6 +112,9 @@ Bugs fixed
* Coverage reporting did not include the signature line of ``cdef`` functions.
(Github issue #1461)
* Casting a GIL-requiring function into a nogil function now issues a warning.
(Github issue #2879)
0.29.6 (2019-02-27)
===================
......
......@@ -10448,7 +10448,8 @@ class TypecastNode(ExprNode):
error(self.pos, "Python objects cannot be cast from pointers of primitive types")
else:
# Should this be an error?
warning(self.pos, "No conversion from %s to %s, python object pointer used." % (self.operand.type, self.type))
warning(self.pos, "No conversion from %s to %s, python object pointer used." % (
self.operand.type, self.type))
self.operand = self.operand.coerce_to_simple(env)
elif from_py and not to_py:
if self.type.create_from_py_utility_code(env):
......@@ -10457,7 +10458,8 @@ class TypecastNode(ExprNode):
if not (self.type.base_type.is_void or self.type.base_type.is_struct):
error(self.pos, "Python objects cannot be cast to pointers of primitive types")
else:
warning(self.pos, "No conversion from %s to %s, python object pointer used." % (self.type, self.operand.type))
warning(self.pos, "No conversion from %s to %s, python object pointer used." % (
self.type, self.operand.type))
elif from_py and to_py:
if self.typecheck:
self.operand = PyTypeTestNode(self.operand, self.type, env, notnone=True)
......@@ -10469,6 +10471,13 @@ class TypecastNode(ExprNode):
elif self.operand.type.is_fused:
self.operand = self.operand.coerce_to(self.type, env)
#self.type = self.operand.type
if self.type.is_ptr and self.type.base_type.is_cfunction and self.type.base_type.nogil:
op_type = self.operand.type
if op_type.is_ptr:
op_type = op_type.base_type
if op_type.is_cfunction and not op_type.nogil:
warning(self.pos,
"Casting a GIL-requiring function into a nogil function circumvents GIL validation", 1)
return self
def is_simple(self):
......
......@@ -7580,12 +7580,14 @@ class TryFinallyStatNode(StatNode):
code.funcstate.in_try_finally = was_in_try_finally
code.putln("}")
code.set_all_labels(old_labels)
temps_to_clean_up = code.funcstate.all_free_managed_temps()
code.mark_pos(self.finally_clause.pos)
code.putln("/*finally:*/ {")
# Reset labels only after writing out a potential line trace call for correct nogil error handling.
code.set_all_labels(old_labels)
def fresh_finally_clause(_next=[self.finally_clause]):
# generate the original subtree once and always keep a fresh copy
node = _next[0]
......
# mode: error
# tag: warnings
cdef extern from *:
cdef void f()
cdef void (*fp)() nogil
cdef void f()
cdef void (*fp)() nogil
ctypedef void (*fp_t)() nogil
fp = f
fp = <fp_t>f
_ERRORS = u"""
7:5: Cannot assign type 'void (void)' to 'void (*)(void) nogil'
9:5: Cannot assign type 'void (void)' to 'void (*)(void) nogil'
"""
_WARNINGS = """
10:5: Casting a GIL-requiring function into a nogil function circumvents GIL validation
"""
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