Re: [Cython] Compiler crash fix

2013-05-24 Thread Stefan Behnel
Am 22.05.2013 11:48, schrieb mark florisson:
> On 22 May 2013 10:13, Nikita Nemkin wrote:
>> Someone please apply this patch (too simple for pull request):
>>
>> diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py
>> index 0406fad..640d002 100755
>> --- a/Cython/Compiler/ExprNodes.py
>> +++ b/Cython/Compiler/ExprNodes.py
>> @@ -4993,7 +4993,7 @@ class AttributeNode(ExprNode):
>># creates a corresponding NameNode and returns it, otherwise
>># returns None.
>>type = self.obj.analyse_as_extension_type(env)
>> -if type:
>> +if type and type.scope:
>>entry = type.scope.lookup_here(self.attribute)
>>if entry and entry.is_cmethod:
>>if type.is_builtin_type:
>>
>> It fixes CompilerCrash (None does not have "lookup_here" method)
>> that I have observed on two occasions:
>> 1) cdef class Name; cimport Name; Name.attr
>> 2) from X cimport Name; Name.attr  # cimport_from_pyx is active, Name is a
>> class with errors
>>
>> Makes me wonder if ErrorScope should be introduced to avoid None scope
>> checks.
> 
> Pull requests are useful not just for large patches, but for small
> ones since they serve as documentation, assign credit to the right
> person, and allow the merger to observe the travis-ci results. The
> ease with which things can be merged contribute largely to it getting
> merged.

All of the above, plus: once there's a test associated with a bug fix,
the patch usually stops looking "too short to merit a pull request". And
tests are the only way to make sure that bugs don't come back, i.e. that
the patch is not wasted in the long run.

Stefan

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


Re: [Cython] How should be C-clobal deletion handled?

2013-05-24 Thread Robert Bradshaw
On Thu, May 23, 2013 at 10:02 PM, Vitja Makarov  wrote:
> Hi!
>
> Recently I've found that the following code causes segmentation fault:
>
> cdef object f
> del f
> print f
>
> So the question is: how should that work?
>
> global objects are implicitly initialized to None and no CF and no cf
> analysis is performed for it.
>
> So I see three options here:
>
> 1. prohibit cglobal deletion
> 2. set it back to None
> 3. check for a null value at every reference and assignment

I'd go for 1, with 2 as a backup option.

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