function causing core dump
Robert Brewer
fumanchu at amor.org
Mon May 10 11:35:06 EDT 2004
Xaver Hinterhuber wrote:
> I build a function with the following code segment:
>
> codeObject = new.code(
> 0, # argcount
> 0, # nlocals
> 0, # stacksize
> 0, # flags
> codeString, # code
> (), # consts
> (), # names
> (), # varnames
> 'content', # filename
> 'content', # name
> 3, # first line number
> codeString # lnotab
> )
> f = new.function(codeObject, dict, 'f')
> f()
>
> Everything runs fine, until the function is called with f().
> When python tries to execute f(), the core dump happens.
> I don't have any clue why python core dumps.
> The codeString is nothing complex, its a one-liner.
> Could you plz give me some tips what I have to do?
As usual, the tip is: include the one piece of information you left out
of your post. What is the value of codeString?
My first guess is that codeString is something like "return None", or
some other string of uncompiled Python code, in which case, you should
use eval() instead of new.code and new.function. Those two are used for
creating code objects and functions from a _compiled_ codestring, like
'\x88\x00\x00Sd\x00\x00S'. In addition, nearly all of the args passed to
new.code are *very* important, and cannot simply be set to 0.
If you want more info, show us the codeString! :)
Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org
More information about the Python-list
mailing list