Hello,
In continuing to play around with the annotation function, I've found
another bug (and I think I have it patched as well). For me, it shows
up when there is an error in my code. It doesn't seem to matter what
that error is, as I've fixed several and still get the same backtrace.
This is in r1071
After running cython -a transforms.pyx, it prints out an error message
and then raises
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 698, in main
result = compile(sources, options)
File
"/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py",
line 675, in compile
return compile_multiple(source, options)
File
"/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py",
line 645, in compile_multiple
result = run_pipeline(source, options)
File
"/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py",
line 507, 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 273, in generate_c_code
self.generate_declarations_for_modules(env, modules, h_code)
File
"/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py",
line 387, in generate_declarations_for_modules
env, modules, vtab_list, vtabslot_list, code)
File
"/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py",
line 376, in generate_type_definitions
self.generate_obj_struct_definition(entry.type, code)
File
"/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py",
line 704, in generate_obj_struct_definition
code.mark_pos(type.pos)
File
"/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Annotate.py",
line 44, in mark_pos
if self.last_pos:
AttributeError: 'AnnotationCCodeWriter' object has no attribute 'last_pos'
The problem is that self.last_pos is not always assigned in the
constructor of AnnotationCCodeWriter, which seems to be the case on my
code. I've attached a patch which fixes it for me
(patch-last_pos.diff). In looking at the code, it seems that
"self.annotator = StringIO()" can be moved inside the "if create_from
is None:" block. If that's the case, then the second patch
(patch-full.diff) does that as well.
--Hoyt
--
+++++++++++++++++++++++++++++++++++
Hoyt Koepke
UBC Department of Computer Science
http://www.cs.ubc.ca/~hoytak/
[EMAIL PROTECTED]
+++++++++++++++++++++++++++++++++++
diff -r 72eb8b27a3d1 Cython/Compiler/Annotate.py
--- a/Cython/Compiler/Annotate.py Mon Aug 18 07:49:35 2008 +0200
+++ b/Cython/Compiler/Annotate.py Mon Aug 18 11:09:44 2008 +0300
@@ -19,10 +19,11 @@
def __init__(self, create_from=None, buffer=None, copy_formatting=True):
CCodeWriter.__init__(self, create_from, buffer, copy_formatting=True)
- self.annotation_buffer = StringIO()
+ self.last_pos = None
+
if create_from is None:
+ self.annotation_buffer = StringIO()
self.annotations = []
- self.last_pos = None
self.code = {}
else:
# When creating an insertion point, keep references to the same database
diff -r 72eb8b27a3d1 Cython/Compiler/Annotate.py
--- a/Cython/Compiler/Annotate.py Mon Aug 18 07:49:35 2008 +0200
+++ b/Cython/Compiler/Annotate.py Mon Aug 18 11:09:27 2008 +0300
@@ -20,9 +20,10 @@
def __init__(self, create_from=None, buffer=None, copy_formatting=True):
CCodeWriter.__init__(self, create_from, buffer, copy_formatting=True)
self.annotation_buffer = StringIO()
+ self.last_pos = None
+
if create_from is None:
self.annotations = []
- self.last_pos = None
self.code = {}
else:
# When creating an insertion point, keep references to the same database
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev