忽略抛出并在库中捕获的异常 [英] Ignore exceptions thrown and caught inside a library
问题描述
我使用的Python标准库和其他库(例如PyQt)有时会在非错误条件下使用异常。查看以下内容,除了函数 os.get_exec_path()
。它使用多个 try
语句来捕获在尝试查找一些环境数据时抛出的异常。
The Python standard library and other libraries I use (e.g. PyQt) sometimes use exceptions for non-error conditions. Look at the following except of the function os.get_exec_path()
. It uses multiple try
statements to catch exceptions that are thrown while trying to find some environment data.
try:
path_list = env.get('PATH')
except TypeError:
path_list = None
if supports_bytes_environ:
try:
path_listb = env[b'PATH']
except (KeyError, TypeError):
pass
else:
if path_list is not None:
raise ValueError(
"env cannot contain 'PATH' and b'PATH' keys")
path_list = path_listb
if path_list is not None and isinstance(path_list, bytes):
path_list = fsdecode(path_list)
这些异常并不表示错误,在正常条件下投掷。对于这些异常之一,当使用异常断点时,调试器也将在这些库函数中中断。
These exceptions do not signify an error and are thrown under normal conditions. When using exception breakpoints for one of these exceptions, the debugger will also break in these library functions.
PyCharm或Python中有一种方法可以让调试器不会破坏抛出并被抓到库中的异常,而不涉及我的代码?
Is there a way in PyCharm or in Python in general to have the debugger not break on exceptions that are thrown and caught inside a library without any involvement of my code?
推荐答案
此功能尚未实施,您可以投票选择:
This feature is not implemented yet, you can vote for it:
- add ability to break (add breakpoint) on exceptions only for my files
这篇关于忽略抛出并在库中捕获的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!