Commit 12b64d68 authored by Stefan Behnel's avatar Stefan Behnel

prevent inheriting from PyVarObjects: tuple, bytes and str

parent cba8fe49
......@@ -3203,6 +3203,10 @@ class CClassDefNode(ClassDefNode):
base_class_entry.type.scope.directives['final']:
error(self.pos, "Base class '%s' of type '%s' is final" % (
self.base_class_name, self.class_name))
elif base_class_entry.type.is_builtin_type and \
base_class_entry.type.name in ('tuple', 'str', 'bytes'):
error(self.pos, "inheritance from PyVarObject types like '%s' is not currently supported"
% base_class_entry.type.name)
else:
self.base_type = base_class_entry.type
has_body = self.body is not None
......
# current restriction: cannot inherit from PyVarObject (see ticket #152)
cdef class MyTuple(tuple):
pass
cdef class MyBytes(bytes):
pass
cdef class MyStr(str): # only in Py2, but can't know that during compilation
pass
_ERRORS = """
4:5: inheritance from PyVarObject types like 'tuple' is not currently supported
7:5: inheritance from PyVarObject types like 'bytes' is not currently supported
10:5: inheritance from PyVarObject types like 'str' is not currently supported
"""
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