Skip to content

Commit

Permalink
BUG: Fix exception handling for python 3k.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Muller authored and pv committed Nov 20, 2010
1 parent 02f61bc commit f1f52d6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions numpy/ctypeslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def load_library(libname, loader_path):
"with ctypes < 1.0.1")

ext = os.path.splitext(libname)[1]

if not ext:
# Try to load library with platform-specific name, otherwise
# default to libname.[so|pyd]. Sometimes, these files are built
Expand All @@ -112,14 +111,15 @@ def load_library(libname, loader_path):
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, e:
pass

raise e
exc = e
raise exc

ctypes_load_library = deprecate(load_library, 'ctypes_load_library',
'load_library')
Expand Down

0 comments on commit f1f52d6

Please sign in to comment.