Commit cbbcdbb3 authored by Robert Bradshaw's avatar Robert Bradshaw

Fix withgil vs nogil patching.

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