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:
[EMAIL PROTECTED]:~/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
[EMAIL PROTECTED]:~/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/
[EMAIL PROTECTED]
+++++++++++++++++++++++++++++++++++
--
+++++++++++++++++++++++++++++++++++
Hoyt Koepke
UBC Department of Computer Science
http://www.cs.ubc.ca/~hoytak/
[EMAIL PROTECTED]
+++++++++++++++++++++++++++++++++++
diff -r e5976a417edf Cython/Compiler/Nodes.py
--- a/Cython/Compiler/Nodes.py Sat Aug 16 04:25:51 2008 -0700
+++ b/Cython/Compiler/Nodes.py Sat Aug 16 16:51:48 2008 +0300
@@ -3041,7 +3041,7 @@
def annotate(self, code):
for cond in self.conditions:
cond.annotate(code)
- body.annotate(code)
+ self.body.annotate(code)
class SwitchStatNode(StatNode):
# Generated in the optimization of an if-elif-else node
@@ -3065,7 +3065,8 @@
self.test.annotate(code)
for case in self.cases:
case.annotate(code)
- self.else_clause.annotate(code)
+ if self.else_clause is not None:
+ self.else_clause.annotate(code)
class LoopNode:
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev