compilation - Python: getting segmentation fault when using compile/eval -


code:

import ast  globalsdict = {}  fast = ast.functiondef(     name="foo",     args=ast.arguments(args=[], vararg=none, kwarg=none, defaults=[]),     body=[], decorator_list=[])  exprast = ast.interactive(body=[fast]) ast.fix_missing_locations(exprast) compiled = compile(exprast, "<foo>", "single") eval(compiled, globalsdict, globalsdict)  print globalsdict["foo"] 

with both cpython , pypy, getting segmentation fault. why?


i guess function definition must not have empty body. tested code adding no-op statement function body:

fast = ast.functiondef(     # ...     body=[ast.pass()],     # ... 

and segmentation fault gone; output is:

<function foo @ 0x022db3f0>

if correct, bug in ast module, since should check empty body.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -