Commit 870aedff authored by Robert Bradshaw's avatar Robert Bradshaw

Error for Python objects as C++ class template parameters.

parent c445411f
......@@ -3046,6 +3046,14 @@ class CppClassType(CType):
error(pos, "%s templated type receives %d arguments, got %d" %
(self.name, len(self.templates), len(template_values)))
return error_type
has_object_template_param = False
for value in template_values:
if value.is_pyobject:
has_object_template_param = True
error(pos,
"Python object type '%s' cannot be used as a template argument" % value)
if has_object_template_param:
return error_type
return self.specialize(dict(zip(self.templates, template_values)))
def specialize(self, values):
......
# mode: error
from libcpp.vector cimport vector
cdef class A:
pass
def main():
cdef vector[object] vo
vo.push_back(object())
cdef vector[A] va
va.push_back(A())
_ERRORS = u"""
9:16: Python object type 'Python object' cannot be used as a template argument
11:16: Python object type 'A' cannot be used as a template argument
"""
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