diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2014-03-24 18:09:10 -0700 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2014-03-24 18:26:56 -0700 |
commit | ac8b59ee335967efef974ab0aa89128ade9f3d0c (patch) | |
tree | 22df573a4b55716470ddbde9ce91279f5c264607 /gi/importer.py | |
parent | e604ada06a8ef8f9a06f0638cf183cfeacdc63a9 (diff) | |
download | pygobject-ac8b59ee335967efef974ab0aa89128ade9f3d0c.tar.gz |
Raise ImportError when importing modules not found in repository
Raise an ImportError with extra information noting the typelib was not
found. This removes the need to log a similar message which adds output
noise when attempting controlled imports within try/except statements.
In Python 2, the additional information is lost but in Python 3 it shows up.
https://bugzilla.gnome.org/show_bug.cgi?id=726877
Diffstat (limited to 'gi/importer.py')
-rw-r--r-- | gi/importer.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gi/importer.py b/gi/importer.py index aa95cf65..cea0f8b0 100644 --- a/gi/importer.py +++ b/gi/importer.py @@ -21,7 +21,6 @@ # USA from __future__ import absolute_import -import logging import sys from ._gi import Repository @@ -47,11 +46,11 @@ class DynamicImporter(object): if path != self.path: return - if not repository.enumerate_versions(namespace): - logging.error('Could not find any typelib for %s', namespace) - return None - else: + if repository.enumerate_versions(namespace): return self + else: + raise ImportError('cannot import name %s, ' + 'introspection typelib not found' % namespace) def load_module(self, fullname): if fullname in sys.modules: |