[Pyrex] 0.9.5 'defaults' is it something special now?

Helmut Jarausch jarausch at igpm.rwth-aachen.de
Tue Jan 30 08:33:19 UTC 2007


On 30 Jan, Greg Ewing wrote:
> Helmut Jarausch wrote:
>> the following code snippets worked just fine with Pyrex 0.9.4 but not
>> with 0.9.5
>> 
>> In the .pyx file
>> def Scanner(Line):
>>   cdef NumTotal
>>   ...
>>   cdef defaults
>>   
>>   # set defaults
>>   try :
>>     NumTotal_D, NumSubs_D, NumIns_D, NumDels_D, IgnCase_D = Scanner.defaults
>>     print "taking defaults"
>>   except :
>>     NumTotal_D, NumSubs_D, NumIns_D, NumDels_D, IgnCase_D = 1, 1, 0, 0, True
>>   Mods= None
>> .....
>> 
>> all of these cdef'ed variables are generated except the last one
>> 'defaults'
> 
> The code you posted doesn't refer to the 'defaults' local. Can you
> post the lines which are meant to assign or use it? Pyrex now avoids
> generating declarations for local variables that aren't used, and it
> might be failing for some reason to notice that 'defaults' is being
> used.
> 
>> On the other hand, lateron, there is
>>   __pyx_v_defaults = Py_None; Py_INCREF(Py_None);
> 
> If it really isn't being used, that line shouldn't get generated,
> which is also a bug.

There is a typo in my code which renders it meaningless, 
so it's a strange situation for Pyrex.

There are the following lines in my code

cdef Scanner_defaults   # at the global level
....
def Scanner(Line):
.....
  cdef defaults
.....
  try :
    NumTotal_D, NumSubs_D, NumIns_D, NumDels_D, IgnCase_D = Scanner.defaults
==================================================================>^
that's the typo (old code), it should read Scanner_defaults.

So, Scanner.defaults is only accessed but never initialized
which is definitely an invalid source code.
It's always the hardest part to make software "robust"
against strange users' input.
The reaction of Pyrex is not ideal but it's caused by my
source code.

Thanks for looking into it,
Helmut.

-- 
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany




More information about the Pyrex mailing list