我想在PyDev script written in Jython中设置断点。我尝试了各种配置:
(1)在Eclipse编辑器中设置断点,但没有任何反应。
(2 & 3)通过在脚本中添加以下代码来强制跟踪:
import template_helper
if False:
py_context_type = org.python.pydev.editor.templates.PyContextType
def MyFunc(context):
# option (2) - try pydevd with another eclipse session hosting debug server
#import sys
#sys.path.append(r"... pydev.core_6.3.3.201805051638\pysrc")
#import pydevd; pydevd.settrace()
# option (3) - try pdb
import pdb; pdb.set_trace()
return "some text"
template_helper.AddTemplateVariable(py_context_type, 'mysub', 'A desc', MyFunc)
尝试pydevd (选项2)就会崩溃,并在error_log中添加以下代码行的异常:
Caused by: Traceback (most recent call last):
File "...\org.python.pydev.jython_6.3.3.201805051638\jysrc\template_helper.py", line 20, in resolveAll
ret = self._callable(context)
File "...\pydev_scripts\src\pytemplate_local.py", line 12, in MyFunc
import pydevd; pydevd.settrace(stdoutToServer=True, stderrToServer=True)
File "...\org.python.pydev.core_6.3.3.201805051638\pysrc\pydevd.py", line 1189, in settrace
_locked_settrace(
File "...\org.python.pydev.core_6.3.3.201805051638\pysrc\pydevd.py", line 1295, in _locked_settrace
debugger.set_tracing_for_untraced_contexts(ignore_frame=get_frame(), overwrite_prev_trace=overwrite_prev_trace)
File "...\org.python.pydev.core_6.3.3.201805051638\pysrc\pydevd.py", line 595, in set_tracing_for_untraced_contexts
for frame in additional_info.iter_frames(t):
File "...\org.python.pydev.core_6.3.3.201805051638\pysrc\_pydevd_bundle\pydevd_additional_thread_info_regular.py", line 117, in iter_frames
current_frames = _current_frames()
File "...\org.python.pydev.core_6.3.3.201805051638\pysrc\_pydevd_bundle\pydevd_additional_thread_info_regular.py", line 26, in _current_frames
as_array = thread_states.entrySet().toArray()
AttributeError: 'java.lang.ThreadLocal' object has no attribute 'entrySet'
尝试简单的pdb (选项3)在PyDev脚本控制台中打印(Pdb)提示符,但用户无法输入任何文本并进入交互模式,例如:
(Pdb) IOError: IOError(...nvalid',)
> ...\org.python.pydev.jython_6.3.3.201805051638\jysrc\template_helper.py(20)resolveAll()
-> ret = self._callable(context)
(Pdb)
也许这是不可能的。有什么建议吗?
发布于 2018-06-07 07:04:30
为了便于将来参考,我最终能够通过下载jython 2.7.1 installer from maven来调试脚本。然后,我将这个jython安装到一个临时位置。在备份与pydev捆绑在一起的jython插件文件夹后,我复制并粘贴了pydev jython安装程序上的相关目录以及pydevd包的副本。在按照上面选项(2)中的描述设置断点之后,我能够在Eclipse的单独实例中单步执行调试。
感谢您在@FabioZadrozny的评论中的帮助。
https://stackoverflow.com/questions/50543332
复制相似问题