diff options
author | njsmith <njs@pobox.com> | 2013-04-02 07:14:49 -0700 |
---|---|---|
committer | njsmith <njs@pobox.com> | 2013-04-02 07:14:49 -0700 |
commit | 5b74363e020f90f09dd41916dfc749d56421b3fa (patch) | |
tree | d00b2dad23f191e214c5ade7932d816d4c2c1c02 /numpy | |
parent | 134bcb0057007c4d821b911eb7b0df1797b054bd (diff) | |
parent | 5819d28c02e4331318ac05824921d457e48d3c00 (diff) | |
download | numpy-5b74363e020f90f09dd41916dfc749d56421b3fa.tar.gz |
Merge pull request #3185 from charris/fix-pull-475
BUG: Raise immediate error in ctypes.load_library when library is bad.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/ctypeslib.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/numpy/ctypeslib.py b/numpy/ctypeslib.py index e111fdb83..478a49777 100644 --- a/numpy/ctypeslib.py +++ b/numpy/ctypeslib.py @@ -122,15 +122,16 @@ else: else: libdir = loader_path - # Need to save exception when using Python 3k, see PEP 3110. - exc = None for ln in libname_ext: - try: - libpath = os.path.join(libdir, ln) - return ctypes.cdll[libpath] - except OSError as e: - exc = e - raise exc + libpath = os.path.join(libdir, ln) + if os.path.exists(libpath): + try: + return ctypes.cdll[libpath] + except OSError: + ## defective lib file + raise + ## if no successful return in the libname_ext loop: + raise OSError("no file with expected extension") ctypes_load_library = deprecate(load_library, 'ctypes_load_library', 'load_library') |