By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,035 Members | 1,384 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,035 IT Pros & Developers. It's quick & easy.

Using inspect.py in Jython

P: 3
Hi,

I am using Jython based application and trying to use inspect.py in the python files.

Here is my code
Expand|Select|Wrap|Line Numbers
  1. import inspect,os,sys,pprint,imp
  2. def handle_stackframe_without_leak(getframe):
  3.     frame = inspect.currentframe()
  4.     try:
  5.         function = inspect.getframeinfo(getframe)
  6.         print inspect.getargvalues(getframe)
  7.     finally:
  8.         del frame
  9. #
  10. def raja(a):
  11.     handle_stackframe_without_leak(inspect.currentframe())
  12.     print a
  13. #
  14. def callraja():
  15.     handle_stackframe_without_leak(inspect.currentframe())
  16.     raja("raja@ad.com")
  17. #
  18. callraja()
  19. raja("raja@ad.com")
  20.  
When I execute this using python.exe, there are no issues. However, when I use this inside the Jython app, I've received errors.

File "C:\Program Files\jython221ondiffjava\Lib\inspect.py", line 722, in getframeinfo
File "C:\Program Files\jython221ondiffjava\Lib\inspect.py", line 413, in findsource
File "C:\Program Files\jython221ondiffjava\Lib\sre.py", line 179, in compile
File "C:\Program Files\jython221ondiffjava\Lib\sre.py", line 227, in _compile
File "C:\Program Files\jython221ondiffjava\Lib\sre_compile.py", line 437, in compile
File "C:\Program Files\jython221ondiffjava\Lib\sre_compile.py", line 421, in _code
File "C:\Program Files\jython221ondiffjava\Lib\sre_compile.py", line 143, in _compile
ValueError: ('unsupported operand type', 'branch')

at org.python.core.Py.makeException(Unknown Source)
at sre_compile$py._compile$1(C:\Program Files\jython221ondiffjava\Lib\sre_compile.py:143)
at sre_compile$py.call_function(C:\Program Files\jython221ondiffjava\Lib\sre_compile.py)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyFunction.__call__(Unknown Source)
at sre_compile$py._code$11(C:\Program Files\jython221ondiffjava\Lib\sre_compile.py:421)
at sre_compile$py.call_function(C:\Program Files\jython221ondiffjava\Lib\sre_compile.py)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyFunction.__call__(Unknown Source)
at sre_compile$py.compile$12(C:\Program Files\jython221ondiffjava\Lib\sre_compile.py:437)
at sre_compile$py.call_function(C:\Program Files\jython221ondiffjava\Lib\sre_compile.py)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyFunction.__call__(Unknown Source)
at org.python.core.PyObject.invoke(Unknown Source)
at sre$py._compile$13(C:\Program Files\jython221ondiffjava\Lib\sre.py:227)
at sre$py.call_function(C:\Program Files\jython221ondiffjava\Lib\sre.py)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyFunction.__call__(Unknown Source)
at sre$py.compile$8(C:\Program Files\jython221ondiffjava\Lib\sre.py:179)
at sre$py.call_function(C:\Program Files\jython221ondiffjava\Lib\sre.py)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyFunction.__call__(Unknown Source)
at org.python.core.PyObject.invoke(Unknown Source)
at inspect$py.findsource$24(C:\Program Files\jython221ondiffjava\Lib\inspect.py:413)
at inspect$py.call_function(C:\Program Files\jython221ondiffjava\Lib\inspect.py)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyFunction.__call__(Unknown Source)
at inspect$py.getframeinfo$54(C:\Program Files\jython221ondiffjava\Lib\inspect.py:722)
at inspect$py.call_function(C:\Program Files\jython221ondiffjava\Lib\inspect.py)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyFunction.__call__(Unknown Source)
at org.python.core.PyObject.invoke(Unknown Source)
at custom$py.handle_stackframe_without_leak$4(C:\Prog ram Files\<my app>\jars\custom.py:29)
at custom$py.call_function(C:\Program Files\<my app>\.\jars\custom.py)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyFunction.__call__(Unknown Source)
at definitions$py.gotonotificationprofile$122(C:\Prog ram Files\<my app>\.\jars\definitions.py:1738)
at definitions$py.call_function(C:\Program Files\<my app>\.\jars\definitions.py)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyFunction.__call__(Unknown Source)
at notificationcases$py.A003$2(C:\Program Files\<my app>\.\jars\notificationcases.py:143)
at notificationcases$py.call_function(C:\Program Files\<my app>\.\jars\notificationcases.py)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyFunction.__call__(Unknown Source)
at org.python.pycode._pyx171.f$0(003:8)
at org.python.pycode._pyx171.call_function(003)
at org.python.core.PyTableCode.call(Unknown Source)
at org.python.core.PyCode.call(Unknown Source)
at org.python.core.Py.runCode(Unknown Source)
at org.python.util.PythonInterpreter.execfile(Unknown Source)
I've tried to find info about this error without success.

Any help will be appreciated.

Thanks
Rajasankar
Jul 10 '09 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.