Hi,
I found a little bug in Cython 0.14.1.
The following causes the Cython compiler to throw an exception:
---8<---
cdef extern from "foo.h":
cdef cppclass foo[ T ]:
bar( int b = 0 )
cdef foo[ int ] a
a.bar( 1 )
---8<---
The exception is "AttributeError: 'CFuncType' object has no attribute
'op_arg_struct'", thrown in line 3044, in generate_result_code. Full
stack trace attached.
The file compiles without crash if one either
- removes the last line, i.e. the call to the class's method, or
- removes the template argument, i.e., the "[ T ]" in line 2 and
the "[ int ]" in line 5.
Hence, the issue only appears when calling methods of _templated_
classes, which have a _default_ value for their argument.
Simon
+---
| Dr. Simon Anders, Dipl.-Phys.
| European Molecular Biology Laboratory (EMBL), Heidelberg
| office phone +49-6221-387-8632
| preferred (permanent) e-mail: sand...@fs.tum.de
$ cython --cplus test2.pyx
Traceback (most recent call last):
File "/usr/local/bin/cython", line 9, in <module>
load_entry_point('Cython==0.14.1', 'console_scripts', 'cython')()
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/Main.py",
line 789, in setuptools_main
return main(command_line = 1)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/Main.py",
line 806, in main
result = compile(sources, options)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/Main.py",
line 781, in compile
return compile_multiple(source, options)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/Main.py",
line 753, in compile_multiple
result = run_pipeline(source, options)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/Main.py",
line 617, in run_pipeline
err, enddata = context.run_pipeline(pipeline, source)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/Main.py",
line 244, in run_pipeline
data = phase(data)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/Main.py",
line 166, in generate_pyx_code
module_node.process_implementation(options, result)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/ModuleNode.py",
line 73, in process_implementation
self.generate_c_code(env, options, result)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/ModuleNode.py",
line 293, in generate_c_code
self.generate_module_init_func(modules[:-1], env,
globalstate['init_module'])
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/ModuleNode.py",
line 1811, in generate_module_init_func
self.body.generate_execution_code(code)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 362, in generate_execution_code
stat.generate_execution_code(code)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 3361, in generate_execution_code
self.expr.generate_evaluation_code(code)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 479, in generate_evaluation_code
self.generate_result_code(code)
File
"/usr/local/lib/python2.6/dist-packages/Cython-0.14.1-py2.6-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 3044, in generate_result_code
func_type.op_arg_struct.base_type, manage_ref=True)
AttributeError: 'CFuncType' object has no attribute 'op_arg_struct'
_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev