Commit cbbcdbb3 authored by Robert Bradshaw's avatar Robert Bradshaw

Fix withgil vs nogil patching.

parent ea0cbaf7
......@@ -2532,6 +2532,19 @@ class CFuncType(CType):
",".join(arg_reprs),
except_clause)
def with_with_gil(self, with_gil):
if with_gil == self.with_gil:
return self
else:
return CFuncType(
self.return_type, self.args, self.has_varargs,
self.exception_value, self.exception_check,
self.calling_convention, self.nogil,
with_gil,
self.is_overridable, self.optional_arg_count,
self.is_const_method, self.is_static_method,
self.templates, self.is_strict_signature)
def calling_convention_prefix(self):
cc = self.calling_convention
if cc:
......
......@@ -735,9 +735,8 @@ class Scope(object):
warning(pos, "Function '%s' previously declared as '%s'" % (
name, 'cpdef' if overridable else 'cdef'), 1)
if entry.type.same_as(type):
# Compatible signatures may have still be different types
# (e.g. nogil vs with gil).
entry.type = type
# Fix with_gil vs nogil.
entry.type = entry.type.with_with_gil(type.with_gil)
else:
if visibility == 'extern' and entry.visibility == 'extern':
can_override = False
......@@ -2085,9 +2084,8 @@ class CClassScope(ClassScope):
if entry.is_final_cmethod and entry.is_inherited:
error(pos, "Overriding final methods is not allowed")
elif type.same_c_signature_as(entry.type, as_cmethod = 1) and type.nogil == entry.type.nogil:
# Compatible signatures may have still be different types
# (e.g. nogil vs with gil).
entry.type = type
# Fix with_gil vs nogil.
entry.type = entry.type.with_with_gil(type.with_gil)
elif type.compatible_signature_with(entry.type, as_cmethod = 1) and type.nogil == entry.type.nogil:
entry = self.add_cfunction(name, type, pos, cname, visibility='ignore', modifiers=modifiers)
else:
......@@ -2222,9 +2220,8 @@ class CppClassScope(Scope):
entry = self.lookup_here(name)
if defining and entry is not None:
if entry.type.same_as(type):
# Compatible signatures may have still be different types
# (e.g. nogil vs with gil).
entry.type = type
# Fix with_gil vs nogil.
entry.type = entry.type.with_with_gil(type.with_gil)
else:
error(pos, "Function signature does not match previous declaration")
else:
......
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