summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authornjsmith <njs@pobox.com>2013-04-02 07:14:49 -0700
committernjsmith <njs@pobox.com>2013-04-02 07:14:49 -0700
commit5b74363e020f90f09dd41916dfc749d56421b3fa (patch)
treed00b2dad23f191e214c5ade7932d816d4c2c1c02 /numpy
parent134bcb0057007c4d821b911eb7b0df1797b054bd (diff)
parent5819d28c02e4331318ac05824921d457e48d3c00 (diff)
downloadnumpy-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.py17
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')