Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IronPython sys._getframe not found

I'm currently building a program in C# which will call functions in provided python script files.
Some of these script files calls _getframe() in sys, which results in the error:

System.MissingMemberException: 'module' object has no attribute '_getframe'

(Since IronPython doesn't have _getframe activated by default.)

I have done quite a lot of googling and found out that you can activate it in ipy.exe by providing -X:Frames as a command line option, however this doesn't solve my problem since I'm not directly using ipy.exe to execute the python code.

In this thread they mention rebuilding IronPython from source with the command line options, I downloaded the source files but have no idea how to build it with those options.
Also they mention that the options are in the official installer, I have run the installer exe several times but haven't seen a glimpse of those options there.

like image 391
Nait Avatar asked Aug 09 '11 14:08

Nait


1 Answers

When creating the PythonEngine you can pass a dictionary of options; you just need to set the "Frames" and/or "FullFrames" keys in the dictionary to true:

var options = new Dictionary<string, object>();
options["Frames"] = true;
options["FullFrames"] = true;
ScriptEngine engine = Python.CreateEngine(options);

If you don't want FullFrames, just leave it out or set it to false.

like image 190
Jeff Hardy Avatar answered Oct 21 '22 04:10

Jeff Hardy