function causing core dump
Peter Otten
__peter__ at web.de
Mon May 10 13:49:15 EDT 2004
Xaver Hinterhuber wrote:
> Hello pythonistas,
>
> 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?
>
> With kind regards
> Xaver Hinterhuber
The easiest approach is probably to start with an attribute set known to be
good:
>>> def f(): pass
...
>>> code = f.func_code
>>> names = dir(code)
>>> names.sort()
>>> for name in names:
... if not name.startswith("_"):
... print "%s=%r" % (name, getattr(code, name))
...
co_argcount=0
co_cellvars=()
co_code='d\x00\x00S'
co_consts=(None,)
co_filename='<stdin>'
co_firstlineno=1
co_flags=67
co_freevars=()
co_lnotab=''
co_name='f'
co_names=()
co_nlocals=0
co_stacksize=1
co_varnames=()
>>>
and change the values until you get a core dump - again.
Peter
More information about the Python-list
mailing list