From fbe26ab64a75753eb4f3baa268e8bfd3b4310a7c Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 13 Apr 2015 15:12:46 +0200 Subject: [PATCH] Importlib might raise a ValueError. Fix #491. --- jedi/_compatibility.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jedi/_compatibility.py b/jedi/_compatibility.py index 290eb520..1a1e943f 100644 --- a/jedi/_compatibility.py +++ b/jedi/_compatibility.py @@ -20,7 +20,12 @@ def find_module_py33(string, path=None): loader = importlib.machinery.PathFinder.find_module(string, path) if loader is None and path is None: # Fallback to find builtins - loader = importlib.find_loader(string) + try: + loader = importlib.find_loader(string) + except ValueError as e: + # See #491. Importlib might raise a ValueError, to avoid this, we + # just raise an ImportError to fix the issue. + raise ImportError("Originally ValueError: " + e.message) if loader is None: raise ImportError("Couldn't find a loader for {0}".format(string))