Error on sys.modules?

I’ve been trying to use the inspect module in a script, however, upon using “inspect.stack()” I would get this error:

[code]Traceback (most recent call last):
File “event:actionPerformed”, line 2, in
File “C:\Documents and Settings\andrey.gueorguiev\Application Data\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\inspect.py”, line 901, in stack
return getouterframes(sys._getframe(1), context)
File “C:\Documents and Settings\andrey.gueorguiev\Application Data\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\inspect.py”, line 882, in getouterframes
framelist.append((frame,) + getframeinfo(frame, context))
File “C:\Documents and Settings\andrey.gueorguiev\Application Data\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\inspect.py”, line 853, in getframeinfo
filename = getsourcefile(frame) or getfile(frame)
File “C:\Documents and Settings\andrey.gueorguiev\Application Data\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\inspect.py”, line 406, in getsourcefile
if hasattr(getmodule(object, filename), ‘loader’):
File “C:\Documents and Settings\andrey.gueorguiev\Application Data\Sun\Java\Deployment\cache\FPMI\script_lib2\Lib\inspect.py”, line 453, in getmodule
main = sys.modules[‘main’]
KeyError: ‘main

Ignition v7.5.6 (b1317)
Java: Sun Microsystems Inc. 1.6.0_38[/code]

The error seems to be coming from sys.modules, because “main” is not a part of it.
Is there any way I can get around this error, or am I just doing something wrong?

Honestly I’m not familiar with the inspect module. I’m guessing it is incompatible with the way we use scripting.

Fixed by adding this before the calling function:

class VirtualModule(object):
	def __init__(self,name):
		import sys
		sys.modules[name]=self
	def __getattr__(self,name):
		return globals()[name]
VirtualModule("__main__")