From 60c2a3bb653e1040def387270a7aa81197cf1015 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Wed, 13 Feb 2019 16:52:25 +0100 Subject: [PATCH] Also raise original error message in util.get_lang_class Otherwise, the true error that happens within a Language subclass is swallowed, because if it's imported lazily like that, it'll always be an ImportError --- spacy/errors.py | 2 +- spacy/util.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spacy/errors.py b/spacy/errors.py index 16713d246..825fc1b35 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -177,7 +177,7 @@ class Errors(object): "you forget to call the `set_extension` method?") E047 = ("Can't assign a value to unregistered extension attribute " "'{name}'. Did you forget to call the `set_extension` method?") - E048 = ("Can't import language {lang} from spacy.lang.") + E048 = ("Can't import language {lang} from spacy.lang: {err}") E049 = ("Can't find spaCy data directory: '{path}'. Check your " "installation and permissions, or use spacy.util.set_data_path " "to customise the location if necessary.") diff --git a/spacy/util.py b/spacy/util.py index 26f3eac2b..621ea5935 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -53,8 +53,8 @@ def get_lang_class(lang): if lang not in LANGUAGES: try: module = importlib.import_module(".lang.%s" % lang, "spacy") - except ImportError: - raise ImportError(Errors.E048.format(lang=lang)) + except ImportError as err: + raise ImportError(Errors.E048.format(lang=lang, err=err)) LANGUAGES[lang] = getattr(module, module.__all__[0]) return LANGUAGES[lang]