From fc17f50d8bf66000b456da3af0986644b5e4dd51 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 15 Jul 2011 19:55:12 +0200 Subject: [PATCH] Rework exception handling logic in freeimage_plugin.py --- scikits/image/io/_plugins/freeimage_plugin.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scikits/image/io/_plugins/freeimage_plugin.py b/scikits/image/io/_plugins/freeimage_plugin.py index d9492f83..8ae5c408 100644 --- a/scikits/image/io/_plugins/freeimage_plugin.py +++ b/scikits/image/io/_plugins/freeimage_plugin.py @@ -32,17 +32,20 @@ def _load_library(libname, loader_path): libdir = os.path.dirname(loader_path) else: libdir = loader_path + if sys.platform == 'win32': + loader = ctypes.windll + else: + loader = ctypes.cdll for ln in libname_ext: try: - libpath = os.path.join(libdir, ln) - if sys.platform == 'win32': - return ctypes.windll[libpath] - else: - return ctypes.cdll[libpath] - except OSError, e: + return loader[os.path.join(libdir, ln)] + except OSError: pass + # TODO: Setup errno and other bits to something correctly + raise OSError( + 'Unable to find library in any of the foloowing paths: %s' % + [os.path.join(libdir, ln) for ln in libname_ext]) - raise e lib_dirs = [os.path.dirname(__file__), '/lib',