Py_CompileString("lambda x : x == 2", ...) aborts

Mike Romberg romberg at smaug.fsl.noaa.gov
Tue Jun 27 13:35:16 EDT 2000


  I am attempting to convert a C++ string which holds the code for a
python lambda function into a PyObject so that I may use it in a later
call.  The code I'm using looks something like this:

PyObject *po = Py_CompileString("lambda x : x == 2", "<string>", 0);

This results in the process exiting with an abort():

Assertion failed
Abort (core dumped)

The stack trace looks like this:

#0  0x4011a111 in __kill ()
#1  0x40119d66 in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x4011b447 in abort () at ../sysdeps/generic/abort.c:88
#3  0x8090e09 in PyGrammar_FindDFA (g=0x819b420, type=0) at grammar1.c:50
#4  0x80bb807 in PyParser_New (g=0x819b420, start=0) at parser.c:129
#5  0x809116d in parsetok (tok=0x822f530, g=0x819b420, start=0, 
    err_ret=0xbffff42c) at parsetok.c:137
#6  0x80910a4 in PyParser_ParseString (s=0x81f7fa0 "lambda x : x == 2", 
    g=0x819b420, start=0, err_ret=0xbffff42c) at parsetok.c:78
#7  0x808d53a in PyParser_SimpleParseString (
    str=0x81f7fa0 "lambda x : x == 2", start=0) at pythonrun.c:966
#8  0x808d4b2 in Py_CompileString (str=0x81f7fa0 "lambda x : x == 2", 
    filename=0x8162481 "<string>", start=0) at pythonrun.c:932

  I'm wondering if someone may see what I'm doing wrong.  Or just be
able to tell me that I can't use lambdas like this.

Thanks,

Mike Romberg (romberg at fsl.noaa.gov)



More information about the Python-list mailing list