Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspect source of exception and filter out of module scope #40

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Prev Previous commit
small changes to excepthook with module whitelist
  • Loading branch information
zomglings committed Apr 27, 2021
commit 80141515e7f0c5be5a022c42e17465a9e509ef9c
11 changes: 7 additions & 4 deletions python/humbug/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,14 @@ def _hook(exception_type, exception_instance, traceback):
original_excepthook(exception_type, exception_instance, traceback)

module = inspect.getmodule(exception_type)
if module is not None and modules_whitelist is not None:
report_error = False
for module_whitelist in modules_whitelist:
if module.__name__.startswith(module_whitelist):
report_error = False
if modules_whitelist is None:
report_error = True
elif module is not None and modules_whitelist is not None:
for whitelisted_module in modules_whitelist:
if module.__name__.startswith(whitelisted_module):
report_error = True

if report_error:
self.error_report(
error=exception_instance, tags=tags, publish=publish
Expand Down