16 Aug 16:05
[Cython] Fwd: some errors annotating code
From: Hoyt Koepke <hoytak@...>
Subject: [Cython] Fwd: some errors annotating code
Newsgroups: gmane.comp.python.cython.devel
Date: 2008-08-16 14:05:02 GMT
Subject: [Cython] Fwd: some errors annotating code
Newsgroups: gmane.comp.python.cython.devel
Date: 2008-08-16 14:05:02 GMT
Hello, I've been playing around with the cython code annotation feature, and I think I've found a couple easily fixable bugs in the html code annotation feature. I'm using the latest version from the mercurial repository (1053:e5976a417edf). First bug. I get the following backtrace: hoytak <at> ubuntu804desktop:~/workspace/clsynth-cython/clsynth$ cython -a transforms.pyx Traceback (most recent call last): File "/home/hoytak/sysroot/bin/cython", line 8, in <module> main(command_line = 1) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 694, in main result = compile(sources, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 671, in compile return compile_multiple(source, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 641, in compile_multiple result = run_pipeline(source, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 503, in run_pipeline err, enddata = context.run_pipeline(pipeline, source) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 169, in run_pipeline data = phase(data) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 114, in generate_pyx_code module_node.process_implementation(options, result) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 67, in process_implementation self.generate_c_code(env, options, result) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 283, in generate_c_code self.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 157, in annotate self.body.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 157, in annotate self.body.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 3067, in annotate case.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 3044, in annotate body.annotate(code) NameError: global name 'body' is not defined It seems this error can be fixed by adding a "self." in 3044 in Nodes.py (see attached patch). When this is fixed, I get another error, namely hoytak <at> ubuntu804desktop:~/workspace/clsynth-cython/clsynth$ cython -a transforms.pyx Traceback (most recent call last): File "/home/hoytak/sysroot/bin/cython", line 8, in <module> main(command_line = 1) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 694, in main result = compile(sources, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 671, in compile return compile_multiple(source, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 641, in compile_multiple result = run_pipeline(source, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 503, in run_pipeline err, enddata = context.run_pipeline(pipeline, source) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 169, in run_pipeline data = phase(data) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 114, in generate_pyx_code module_node.process_implementation(options, result) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 67, in process_implementation self.generate_c_code(env, options, result) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 283, in generate_c_code self.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 157, in annotate self.body.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 157, in annotate self.body.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 3068, in annotate self.else_clause.annotate(code) AttributeError: 'NoneType' object has no attribute 'annotate' The documentation for this method says that self.else_clause can be None, so I assume adding a test for that works as a patch. After doing that, everything works fine for me. I attached the patch; let me know if I'm missing something If you want me to file a bug report, I can do that also. --Hoyt -- +++++++++++++++++++++++++++++++++++ Hoyt Koepke UBC Department of Computer Science http://www.cs.ubc.ca/~hoytak/ hoytak@... +++++++++++++++++++++++++++++++++++ -- +++++++++++++++++++++++++++++++++++ Hoyt Koepke UBC Department of Computer Science http://www.cs.ubc.ca/~hoytak/ hoytak@... +++++++++++++++++++++++++++++++++++
Hello, I've been playing around with the cython code annotation feature, and I think I've found a couple easily fixable bugs in the html code annotation feature. I'm using the latest version from the mercurial repository (1053:e5976a417edf). First bug. I get the following backtrace: hoytak <at> ubuntu804desktop:~/workspace/clsynth-cython/clsynth$ cython -a transforms.pyx Traceback (most recent call last): File "/home/hoytak/sysroot/bin/cython", line 8, in <module> main(command_line = 1) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 694, in main result = compile(sources, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 671, in compile return compile_multiple(source, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 641, in compile_multiple result = run_pipeline(source, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 503, in run_pipeline err, enddata = context.run_pipeline(pipeline, source) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 169, in run_pipeline data = phase(data) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 114, in generate_pyx_code module_node.process_implementation(options, result) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 67, in process_implementation self.generate_c_code(env, options, result) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 283, in generate_c_code self.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 157, in annotate self.body.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 157, in annotate self.body.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 3067, in annotate case.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 3044, in annotate body.annotate(code) NameError: global name 'body' is not defined It seems this error can be fixed by adding a "self." in 3044 in Nodes.py (see attached patch). When this is fixed, I get another error, namely hoytak <at> ubuntu804desktop:~/workspace/clsynth-cython/clsynth$ cython -a transforms.pyx Traceback (most recent call last): File "/home/hoytak/sysroot/bin/cython", line 8, in <module> main(command_line = 1) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 694, in main result = compile(sources, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 671, in compile return compile_multiple(source, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 641, in compile_multiple result = run_pipeline(source, options) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 503, in run_pipeline err, enddata = context.run_pipeline(pipeline, source) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 169, in run_pipeline data = phase(data) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 114, in generate_pyx_code module_node.process_implementation(options, result) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 67, in process_implementation self.generate_c_code(env, options, result) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 283, in generate_c_code self.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 157, in annotate self.body.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 157, in annotate self.body.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 287, in annotate stat.annotate(code) File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 3068, in annotate self.else_clause.annotate(code) AttributeError: 'NoneType' object has no attribute 'annotate' The documentation for this method says that self.else_clause can be None, so I assume adding a test for that works as a patch. After doing that, everything works fine for me. I attached the patch; let me know if I'm missing something If you want me to file a bug report, I can do that also. --Hoyt -- +++++++++++++++++++++++++++++++++++ Hoyt Koepke UBC Department of Computer Science http://www.cs.ubc.ca/~hoytak/ hoytak@... +++++++++++++++++++++++++++++++++++ -- -- +++++++++++++++++++++++++++++++++++ Hoyt Koepke UBC Department of Computer Science http://www.cs.ubc.ca/~hoytak/ hoytak@... +++++++++++++++++++++++++++++++++++
RSS Feed