关于'finally'字的Jython语法错误

时间:2012-03-13 14:19:08

标签: python exception-handling jython grinder

这是导致错误的代码段:

net.grinder.scriptengine.jython.JythonScriptExecutionException: SyntaxError: ('invalid syntax', ('C:\\grinder-3.7.1\\lib
\\.\\nb-romg-file-store\\current\\grinder_test.py', 131, 9, '        finally:'))


    ss = ''
    self._suggestionLock.acquire()
    try:
        ss = suggestion_strings.next()
    except StopIteration:
        suggestion_strings = suggestions_generator()
        ss = suggestion_strings.next()
    finally:
        self._suggestionLock.release()

这里可能有什么问题?

2 个答案:

答案 0 :(得分:5)

您使用的是Jython 2.4吗?在Python 2.5中引入了try / except / finally。

答案 1 :(得分:1)

您只支持Python 2.4的Jython; 2.5中添加了try ... except ... finally