Feuermurmel Feuermurmel - 1 year ago 75
Python Question

Ignore exceptions thrown and caught inside a library

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

. It uses multiple
statements to catch exceptions that are thrown while trying to find some environment data.

path_list = env.get('PATH')
except TypeError:
path_list = None

if supports_bytes_environ:
path_listb = env[b'PATH']
except (KeyError, TypeError):
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.

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?

Answer Source

This feature is not implemented yet, you can vote for it:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download