Yes, this looks correct. Thanks.

On Aug 18, 2008, at 6:50 AM, Dag Sverre Seljebotn wrote:

> Dag Sverre Seljebotn wrote:
>> Hoyt Koepke wrote:
>>> 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
>>>
>>> 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
>> I believe the right thing to do here is to copy last_pos in  
>> create_from (see below), but I'm not commiting as I'd like Robert  
>> to confirm (as there's going to be a release today). The cleanup  
>> of self.annotator is correct.
>> Thanks!
>
> Attaching a patch properly doing the above.
>
> -- 
> Dag Sverre
> diff -r 265a5de27a1b Cython/Compiler/Annotate.py
> --- a/Cython/Compiler/Annotate.py     Mon Aug 18 15:49:36 2008 +0200
> +++ b/Cython/Compiler/Annotate.py     Mon Aug 18 15:50:03 2008 +0200
> @@ -19,8 +19,8 @@ class AnnotationCCodeWriter(CCodeWriter)
>
>      def __init__(self, create_from=None, buffer=None,  
> copy_formatting=True):
>          CCodeWriter.__init__(self, create_from, buffer,  
> copy_formatting=True)
> -        self.annotation_buffer = StringIO()
>          if create_from is None:
> +            self.annotation_buffer = StringIO()
>              self.annotations = []
>              self.last_pos = None
>              self.code = {}
> @@ -28,6 +28,7 @@ class AnnotationCCodeWriter(CCodeWriter)
>              # When creating an insertion point, keep references to  
> the same database
>              self.annotation_buffer = create_from.annotation_buffer
>              self.annotations = create_from.annotations
> +            self.last_pos = create_from.last_pos
>              self.code = create_from.code
>
>      def create_new(self, create_from, buffer, copy_formatting):
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to