[Cython] Bug report: compiler traceback instead of error message

2013-07-09 Thread John Benediktsson
Hi,

I had some trouble debugging a traceback that I got from Cython, which
ended up being a simple typo in a .pyx file.  Below is a reduced example of
this problem.

If you have a foo.pxd file (specifying a variable "bar"):

$ cat foo.pxd
cdef class Tree:
cpdef build(self, int bar=*)

And a foo.pyx file (accidentally calling the variable "baz"):

$ cat foo.pyx
cdef class Tree:
cpdef build(self, int baz=None):
print baz

You get this nasty traceback when you try to cython it, which makes you
think there is a bug in Cython instead of a bug in your code:

$ cython foo.pyx
Traceback (most recent call last):
  File "/usr/local/bin/cython", line 9, in 
load_entry_point('Cython==0.19.1', 'console_scripts', 'cython')()
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Main.py", line 618, in
setuptools_main
return main(command_line = 1)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Main.py", line 635, in
main
result = compile(sources, options)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Main.py", line 610, in
compile
return compile_multiple(source, options)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Main.py", line 579, in
compile_multiple
result = run_pipeline(source, options, context=context)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Main.py", line 425, in
run_pipeline
err, enddata = Pipeline.run_pipeline(pipeline, source)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Pipeline.py", line 322,
in run_pipeline
data = phase(data)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Pipeline.py", line 51,
in generate_pyx_code_stage
module_node.process_implementation(options, result)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/ModuleNode.py", line
111, in process_implementation
self.generate_c_code(env, options, result)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/ModuleNode.py", line
342, in generate_c_code
self.body.generate_function_definitions(env, code)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Nodes.py", line 393, in
generate_function_definitions
stat.generate_function_definitions(env, code)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Nodes.py", line 4267,
in generate_function_definitions
self.body.generate_function_definitions(self.scope, code)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Nodes.py", line 393, in
generate_function_definitions
stat.generate_function_definitions(env, code)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Nodes.py", line 1704,
in generate_function_definitions
self.generate_argument_parsing_code(env, code)
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Nodes.py", line 2297,
in generate_argument_parsing_code
self.type.opt_arg_cname(declarator.name)))
  File "/Library/Python/2.7/site-packages/Cython
-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/PyrexTypes.py", line
2684, in opt_arg_cname
return self.op_arg_struct.base_type.scope.lookup(arg_name).cname
AttributeError: 'NoneType' object has no attribute 'cname'

Thanks,
John.
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Bug report: compiler traceback instead of error message

2013-07-09 Thread Robert Bradshaw
Yes, we should be giving an error message here rather than crashing;
thanks for the report.

On Tue, Jul 9, 2013 at 7:36 AM, John Benediktsson  wrote:
> Hi,
>
> I had some trouble debugging a traceback that I got from Cython, which ended
> up being a simple typo in a .pyx file.  Below is a reduced example of this
> problem.
>
> If you have a foo.pxd file (specifying a variable "bar"):
>
> $ cat foo.pxd
> cdef class Tree:
> cpdef build(self, int bar=*)
>
> And a foo.pyx file (accidentally calling the variable "baz"):
>
> $ cat foo.pyx
> cdef class Tree:
> cpdef build(self, int baz=None):
> print baz
>
> You get this nasty traceback when you try to cython it, which makes you
> think there is a bug in Cython instead of a bug in your code:
>
> $ cython foo.pyx
> Traceback (most recent call last):
>   File "/usr/local/bin/cython", line 9, in 
> load_entry_point('Cython==0.19.1', 'console_scripts', 'cython')()
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Main.py",
> line 618, in setuptools_main
> return main(command_line = 1)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Main.py",
> line 635, in main
> result = compile(sources, options)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Main.py",
> line 610, in compile
> return compile_multiple(source, options)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Main.py",
> line 579, in compile_multiple
> result = run_pipeline(source, options, context=context)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Main.py",
> line 425, in run_pipeline
> err, enddata = Pipeline.run_pipeline(pipeline, source)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Pipeline.py",
> line 322, in run_pipeline
> data = phase(data)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Pipeline.py",
> line 51, in generate_pyx_code_stage
> module_node.process_implementation(options, result)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/ModuleNode.py",
> line 111, in process_implementation
> self.generate_c_code(env, options, result)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/ModuleNode.py",
> line 342, in generate_c_code
> self.body.generate_function_definitions(env, code)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Nodes.py",
> line 393, in generate_function_definitions
> stat.generate_function_definitions(env, code)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Nodes.py",
> line 4267, in generate_function_definitions
> self.body.generate_function_definitions(self.scope, code)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Nodes.py",
> line 393, in generate_function_definitions
> stat.generate_function_definitions(env, code)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Nodes.py",
> line 1704, in generate_function_definitions
> self.generate_argument_parsing_code(env, code)
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/Nodes.py",
> line 2297, in generate_argument_parsing_code
> self.type.opt_arg_cname(declarator.name)))
>   File
> "/Library/Python/2.7/site-packages/Cython-0.19.1-py2.7-macosx-10.8-intel.egg/Cython/Compiler/PyrexTypes.py",
> line 2684, in opt_arg_cname
> return self.op_arg_struct.base_type.scope.lookup(arg_name).cname
> AttributeError: 'NoneType' object has no attribute 'cname'
>
> Thanks,
> John.
>
> ___
> cython-devel mailing list
> cython-devel@python.org
> http://mail.python.org/mailman/listinfo/cython-devel
>
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel