IronPython compile() does not accept AST object

房东的猫 提交于 2019-12-14 03:59:38

问题


In the documentation it says, 'source' can be either str or AST object

When trying to compile my ast root:

dl = compile(newRoot, '<string>', 'eval')

I get this Exception:

expected str, got Module

I am using the last version of IronPython.

Is there an idea why this does not work? all the examples I found seem to do it this way with no issues.

Is there a workaround to compile an AST object?

Thanks!!!!

PD: I found this issue but seems to have no activity: http://ironpython.codeplex.com/workitem/32526


回答1:


First off, IronPython does not support this.

It's actually quite hard to support in IronPython (and I didn't know it needed to be supported until today). IronPython's _ast module is a wrapper around its own AST, and currently only implements conversion from IronPython AST => CPython AST, but not the reverse. It's a fair bit of (honestly, quite tedious) work, so I'm not sure when it will get fixed.

If there's a popular program or library that's broken because of this that moves it up the priority list, and patches are always welcome.



来源:https://stackoverflow.com/questions/10890192/ironpython-compile-does-not-accept-ast-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!