[Cython] Cython crash when using forward declarations

2013-11-25 Thread Vinay Sajip
The following Cython source:

cdef extern from "header":
cdef cppclass String
cdef cppclass List[T]
cdef cppclass StringList(List[String])

cdef cppclass String:
String()
int length()

cdef cppclass List[T]:
List()
int length()

cdef cppclass StringList(List[String]):
StringList()
void sort()

causes a crash:

Error compiling Cython file:

...

cdef cppclass List[T]:
List()
int length()

cdef cppclass StringList(List[String]):
^


s.pyx:14:9: Cannot inherit from incomplete type

Error compiling Cython file:

...
cdef cppclass List[T]:
List()
int length()

cdef cppclass StringList(List[String]):
StringList()
   ^


s.pyx:15:8: Compiler crash in AnalyseDeclarationsTransform

File 'ModuleNode.py', line 101, in analyse_declarations: ModuleNode(s.pyx:1:0,
full_module_name = 's')
File 'Nodes.py', line 382, in analyse_declarations: StatListNode(s.pyx:1:5)
File 'Nodes.py', line 438, in analyse_declarations: CDefExternNode(s.pyx:1:5,
include_file = u'header')
File 'Nodes.py', line 382, in analyse_declarations: StatListNode(s.pyx:2:4)
File 'Nodes.py', line 1313, in analyse_declarations: CppClassNode(s.pyx:14:9,
base_classes = [...]/1,
name = u'StringList',
visibility = u'extern')
File 'Nodes.py', line 1203, in analyse_declarations: CVarDefNode(s.pyx:15:8,
modifiers = [...]/0,
visibility = u'extern')

Compiler crash traceback from this point on:
  File ".../Cython/Compiler/Nodes.py", line 1203, in analyse_declarations
api = self.api, modifiers = self.modifiers)
  File ".../Cython/Compiler/Symtab.py", line 2131, in declare_cfunction
self.check_base_default_constructor(pos)
  File ".../Cython/Compiler/Symtab.py", line 2108, in \
check_base_default_constructor
temp_entry = base_class.scope.lookup_here("")
AttributeError: 'NoneType' object has no attribute 'lookup_here'

There seem to be two problems here: the AttributeError crash, but also the
earlier "Cannot inherit from incomplete type" message. None of the types look
incomplete; if you comment out the forward declarations, no error is reported:
so it looks as if the forward declarations aren't being tied up with the actual
declarations. In the actual use case, of course, I need the forward decls.

Regards,

Vinay Sajip

___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


[Cython] Seemingly incorrect specialization of templates

2013-12-16 Thread Vinay Sajip
Given this code in Cython/Includes/libcpp/utility.pxd:

cdef extern from "" namespace "std":
cdef cppclass pair[T, U]:
T first
U second
# rest omitted

when the following code in Cython/Includes/libcpp/map.pxd is seen:

from utility cimport pair

cdef extern from "" namespace "std":
cdef cppclass map[T, U]:
cppclass iterator:
pair[T, U]& operator*() nogil
# rest omitted

The line "pair[T, U]& operator*() nogil" causes a specialization
of pair[T, U] to be created, but using placeholders rather than actual
types. This seems wrong - can someone here confirm whether this is
intentional?

This led to a problem where the generated C++ code for a genuine
specialisation instead generated a declaration like "pair" instead
of using the actual arguments. Given this code in
Cython/Includes/libcpp/utility.pxd:

cdef extern from "" namespace "std":
cdef cppclass pair[T, U]:
T first
U second
# rest omitted

when the following code in Cython/Includes/libcpp/map.pxd is seen:

from utility cimport pair

cdef extern from "" namespace "std":
cdef cppclass map[T, U]:
cppclass iterator:
pair[T, U]& operator*() nogil
# rest omitted

The line "pair[T, U]& operator*() nogil" causes a specialization
of pair[T, U] to be created, but using placeholders rather than actual
types. This seems wrong - can someone here confirm whether this is
intentional?

This caused a problem where the generated C++ code for a genuine
specialisation instead generated a declaration like "pair" instead
of using the actual arguments.Given this code in
Cython/Includes/libcpp/utility.pxd:

cdef extern from "" namespace "std":
cdef cppclass pair[T, U]:
T first
U second
# rest omitted

when the following code in Cython/Includes/libcpp/map.pxd is seen:

from utility cimport pair

cdef extern from "" namespace "std":
cdef cppclass map[T, U]:
cppclass iterator:
pair[T, U]& operator*() nogil
# rest omitted

The line "pair[T, U]& operator*() nogil" causes a specialization
of pair[T, U] to be created, but using placeholders rather than actual
types. This seems wrong - can someone here confirm whether this is
intentional?

This caused a problem where the generated C++ code for a genuine
specialisation instead generated a declaration like "pair" instead
of using the actual arguments.

The specialize call occurs in Nodes.py:TemplatedTypeNode.analyse, where the
template_types passed to specialize are actually all instances of
TemplatePlaceholderType.

Regards,

Vinay Sajip
Given this code in Cython/Includes/libcpp/utility.pxd:

cdef extern from "" namespace "std":
cdef cppclass pair[T, U]:
T first
U second
# rest omitted

when the following code in Cython/Includes/libcpp/map.pxd is seen:

from utility cimport pair

cdef extern from "" namespace "std":
cdef cppclass map[T, U]:
cppclass iterator:
pair[T, U]& operator*() nogil
# rest omitted

The line "pair[T, U]& operator*() nogil" causes a specialization
of pair[T, U] to be created, but using placeholders rather than actual
types. This seems wrong - can someone here confirm whether this is
intentional?

This caused a problem where the generated C++ code for a genuine
specialisation instead generated a declaration like "pair" instead
of using the actual arguments. This, of course, failed in g++.

The specialize call occurs in Nodes.py:TemplatedTypeNode.analyse, where the
template_types passed to specialize are actually all instances of
TemplatePlaceholderType. It seems like just the base_type could be used.

Regards,

Vinay Sajip


The specialize call occurs in Nodes.py:TemplatedTypeNode.analyse, where the
template_types passed to specialize are actually all instances of
TemplatePlaceholderType.

Regards,

Vinay Sajip


The specialize call occurs in Nodes.py:TemplatedTypeNode.analyse, where the
template_types passed to specialize are actually all instances of
TemplatePlaceholderType.

Regards,

Vinay Sajip


___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Seemingly incorrect specialization of templates

2013-12-17 Thread Vinay Sajip
Sorry, some parts of my post appear to have been duplicated. Not sure how that 
happened.

Regards,

Vinay Sajip

___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel