PyCharm中断异常不适用于Theano

时间:2015-06-23 16:44:08

标签: python exception-handling pycharm pydev theano

当我导入Theano时,我无法让PyCharm停在引发异常的代码行上。

我的代码:

import theano
raise Exception()

我希望PyCharm调试器停在raise Exception()行,但它会抛出RuntimeError并退出调试器:

Traceback (most recent call last):
Error in sys.excepthook:
Traceback (most recent call last):
  File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd_breakpoints.py", line 89, in _excepthook
    _original_excepthook(exctype, value, tb)
  File "/usr/local/lib/python2.7/dist-packages/theano/gof/link.py", line 58, in thunk_hook
    __excepthook(type, value, trace)
  File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd_breakpoints.py", line 89, in _excepthook
    _original_excepthook(exctype, value, tb)
  File "/usr/local/lib/python2.7/dist-packages/theano/gof/link.py", line 58, in thunk_hook
    __excepthook(type, value, trace)
  <...>
  File "/usr/local/lib/python2.7/dist-packages/theano/gof/link.py", line 58, in thunk_hook
    __excepthook(type, value, trace)
  File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd_breakpoints.py", line 84, in _excepthook
    exception_breakpoint = get_exception_breakpoint(exctype, _handle_exceptions)
  File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd_breakpoints.py", line 65, in get_exception_breakpoint
    exception_full_qname = get_exception_full_qname(exctype)
  File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd_breakpoints.py", line 53, in get_exception_full_qname
    def get_exception_full_qname(exctype):
RuntimeError: maximum recursion depth exceeded

Original exception was:
Traceback (most recent call last):
  File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd.py", line 2357, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/homes/user/Downloads/pycharm-community-4.5.1/helpers/pydev/pydevd.py", line 1777, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/homes/user/corp/python/projects/n_test.py", line 10, in <module>
    raise Exception()
Exception

2 个答案:

答案 0 :(得分:0)

一个黑客就是在sys.excepthook = thunk_hook

中注释掉这一行.../lib/python2.7/site-packages/theano/gof/link.py

答案 1 :(得分:0)

看起来像其中一个库中的错误(可能都是:^))。

出于某种原因,theanoPyCharm的异常都认为另一个是其祖先。

将调试打印添加到两个库中的sys.excepthook点,并将指向前一个处理程序的成员变量设置为显示设置顺序。有人似乎打破了处理程序链规则。