简体   繁体   English

PyCharm中断异常不适用于Theano

[英]PyCharm break on exception does not work with Theano

I cannot get PyCharm to stop on the line of code where an exception is raised, when I import Theano. 当我导入Theano时,我无法让PyCharm停止在引发异常的代码行上。

My code: 我的代码:

import theano
raise Exception()

I expect PyCharm debugger to stop on the raise Exception() line, but it throws a RuntimeError and exits the debugger: 我希望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

一个hack是在.../lib/python2.7/site-packages/theano/gof/link.py sys.excepthook = thunk_hook中注释掉这行sys.excepthook = thunk_hook .../lib/python2.7/site-packages/theano/gof/link.py

Looks like a bug in one of the libs (maybe both :^)). 看起来像其中一个库中的错误(可能都是:^))。

For some reason, theano 's and PyCharm 's excepthooks both think of the other one as its ancestor. 出于某种原因, theanoPyCharm的异常都认为另一个是其祖先。

Add debug printing into both libs at points where sys.excepthook and member variables that point to the previous handler are set to reveal the setting order. 将调试打印添加到两个库中,其中sys.excepthook和指向前一个处理程序的成员变量设置为显示设置顺序。 Someone appears to be breaking the handler chaining rules. 有人似乎打破了处理程序链接规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM