[Pyrex] Unlucky fellow needs help (pyrex crashes)
Helmut Jarausch
jarausch at igpm.rwth-aachen.de
Wed Feb 22 10:03:17 CET 2006
Hi helpful souls,
unfortunately I managed to either crash Pyrex or
to let Pyrex crash my process (segment fault)
What ill things have I committed?
Any help is much appreciated,
Helut
Both cases are only tiny variants by rearranged
code. I try to return a derived object for iteration.
Both are invoked by
import I_Test
IT= I_Test.ITNO()
for i in IT.list(1,3):
print i
---------------------------------
Variant I crashes Pyrex
# Pyrex iterator test
cdef class ITNO # forward declaration
cdef class ITNO_List(ITNO):
cdef int cnt
cdef int From
cdef int To
def __new__(self,int _from, int _to) :
self.From= _from
self.To = _to
def __iter__(self) :
self.cnt= _from-1
return self
def __next__(self):
if self.cnt >= self.To :
raise StopIteration
self.cnt= self.cnt+1
return self.cnt*self.base
cdef class ITNO:
cdef base
def __new__(self):
self.base= 7
def list(self,_from,_to):
return ITNO_List(_from,_to)
----------
it gives
% pyrexc I_Test.pyx
Traceback (most recent call last):
File "/usr/local/bin/pyrexc", line 8, in ?
main(command_line = 1)
File "/usr/local/lib/python2.4/site-packages/Pyrex/Compiler/Main.py", line 271, in main
result = context.compile(source, options)
File "/usr/local/lib/python2.4/site-packages/Pyrex/Compiler/Main.py", line 175, in compile
tree.process_implementation(scope, result)
File "/usr/local/lib/python2.4/site-packages/Pyrex/Compiler/Nodes.py", line 110, in process_implementation
self.analyse_declarations(env)
File "/usr/local/lib/python2.4/site-packages/Pyrex/Compiler/Nodes.py", line 107, in analyse_declarations
self.body.analyse_declarations(env)
File "/usr/local/lib/python2.4/site-packages/Pyrex/Compiler/Nodes.py", line 1264, in analyse_declarations
stat.analyse_declarations(env)
File "/usr/local/lib/python2.4/site-packages/Pyrex/Compiler/Nodes.py", line 2365, in analyse_declarations
typedef_flag = self.typedef_flag)
File "/usr/local/lib/python2.4/site-packages/Pyrex/Compiler/Symtab.py", line 672, in declare_c_class
scope.declare_inherited_c_attributes(base_type.scope)
File "/usr/local/lib/python2.4/site-packages/Pyrex/Compiler/Symtab.py", line 1026, in declare_inherited_c_attributes
for base_entry in \
AttributeError: 'NoneType' object has no attribute 'inherited_var_entries'
=================================================================
Variant II is accepted by pyrexc but
gives a segment fault while running the loop
---------------------
# Pyrex iterator test
cdef class ITNO # forward declaration
cdef class ITNO_List(ITNO) # forward declaration
cdef class ITNO:
cdef base
def __new__(self):
self.base= 7
def list(self, int _from, int _to):
return ITNO_List(_from,_to)
cdef class ITNO_List(ITNO):
cdef int cnt
cdef int From
cdef int To
def __new__(self, int _from, int _to):
self.From= _from
self.To = _to
def __iter__(self) :
self.cnt= self.From-1
return self
def __next__(self):
if self.cnt >= self.To : raise StopIteration
self.cnt= self.cnt+1
return self.cnt*self.base
--
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
More information about the Pyrex
mailing list