2009-07-10 7 views
2

자이 썬에서 개발 한 응용 프로그램을 사용하고 있습니다. inspect.py를 사용하려고하면 오류 메시지가 표시됩니다.자이 썬에서 inspect.py를 사용할 때의 문제점

내 코드는 내가이 사용 python.exe를 실행하면 아무 문제가없는이

import inspect,os,sys,pprint,imp 
def handle_stackframe_without_leak(getframe): 
    frame = inspect.currentframe() 
    try: 
     function = inspect.getframeinfo(getframe) 
     print inspect.getargvalues(getframe) 
    finally: 
     del frame 
# 
def raja(a): 
    handle_stackframe_without_leak(inspect.currentframe()) 
    print a 
# 
def callraja(): 
    handle_stackframe_without_leak(inspect.currentframe()) 
    raja("[email protected]") 
# 
callraja() 
raja("[email protected]") 
# 

처럼 간다. 그러나,이 응용 프로그램 내부에 다음과 같은 오류가 발생

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:\Program 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:\Program 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) 

도움을 주실 수 있습니다.

감사 Rajasankar는

답변

0

http://grinder.sourceforge.net/faq.html#re-problems을 도움이 될 수 있습니다.


def findsource(object): 
    """Return the entire source file and starting line number for an object. 
    (...snip...)""" 
    import re 
    file = getsourcefile(object) or getfile(object) 

하지만 아무것도 약속 할 수 없습니다 ...

:

빠른 체크를 들어, (\ 프로그램 파일 \ jython221ondiffjava \ lib 디렉토리 \ inspect.py C) findsource 방법에 import re를 추가하려고
1

Jython으로 명령 줄에서 프로그램을 실행 해 보았습니까? (앱 외부)? 자이 썬 2.2.1 또는 자이 썬 2.5.0으로 프로그램을 실행하면 파이썬에서와 동일한 결과를 얻는다.

+0

저는 파이썬으로 해봤습니다. 나는 이것을 시도 할 것이다. – Rajasankar

+0

앱이 작동 중입니다. 앱 내부의 re 모듈로 작업 할 수 없습니다. 버전을 확인합니다. – Rajasankar

관련 문제