Commit 5cf7be8f authored by Robert Bradshaw's avatar Robert Bradshaw

Require GIL-holding constructor if base classes require GIL.

This fixes #1986.
parent fff85888
......@@ -2342,6 +2342,12 @@ class CppClassScope(Scope):
cname = "%s__dealloc__%s" % (Naming.func_prefix, class_name)
name = '<del>'
type.return_type = PyrexTypes.CVoidType()
if name in ('<init>', '<del>') and type.nogil:
for base in self.type.base_classes:
base_entry = base.scope.lookup(name)
if base_entry and not base_entry.type.nogil:
error(pos, "Constructor cannot be called without GIL unless all base constructors can also be called without GIL")
error(base_entry.pos, "Base constructor defined here.")
prev_entry = self.lookup_here(name)
entry = self.declare_var(name, type, pos,
defining=defining,
......
# tag: cpp
# mode: error
cdef cppclass Base:
__init__() nogil:
pass
cdef cppclass Sub1(Base):
__init__(): # implicit requires GIL
pass
cdef cppclass Sub2(Sub1):
__init__() nogil:
pass
_ERRORS = u"""
10:4: Base constructor defined here.
14:4: Constructor cannot be called without GIL unless all base constructors can also be called without GIL
"""
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