From b654752c240936596d23b5bfb2e00d2bacbcf50f Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Sat, 1 Oct 2022 02:55:12 +0200 Subject: REV: Losen `lookfor`'s import try/except again (#22356) Some BaseExceptions (at least the Skipped that pytest uses) need to be caught as well. It seems easiest to be practical and keep ignoring almost all exception in this particular code path. Effectively reverts parts of gh-19393 Closes gh-22345 Co-authored-by: Sebastian Berg --- numpy/lib/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'numpy/lib') diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 497827e75..f9d29e89d 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -972,8 +972,12 @@ def _lookfor_generate_cache(module, import_modules, regenerate): finally: sys.stdout = old_stdout sys.stderr = old_stderr - # Catch SystemExit, too - except (Exception, SystemExit): + except KeyboardInterrupt: + # Assume keyboard interrupt came from a user + raise + except BaseException: + # Ignore also SystemExit and pytests.importorskip + # `Skipped` (these are BaseExceptions; gh-22345) continue for n, v in _getmembers(item): -- cgit v1.2.1