From 725c7574a5b99a0a148166b9ccfa6d6e5bd327e9 Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Fri, 26 Jul 2019 21:32:02 -0700 Subject: [PATCH] bots: Use ImportError in Python<3.6 for failed import of bot by name. This previously caused a traceback if the bot couldn't be found. --- zulip_bots/zulip_bots/finder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zulip_bots/zulip_bots/finder.py b/zulip_bots/zulip_bots/finder.py index ff7063e..0c44b1b 100644 --- a/zulip_bots/zulip_bots/finder.py +++ b/zulip_bots/zulip_bots/finder.py @@ -27,7 +27,9 @@ def import_module_by_name(name: Text) -> Any: import importlib try: return importlib.import_module(name) - except ModuleNotFoundError: + except ImportError: + return None + except ModuleNotFoundError: # Specific exception supported >=Python3.6 return None def resolve_bot_path(name: Text) -> Optional[Tuple[Text, Text]]: