summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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')