BUG: Fix FreeImage Py3k compatibility [patch by Almar Klein].

This commit is contained in:
Stefan van der Walt
2012-05-21 18:24:32 -07:00
parent 4f0a2c74cc
commit 34505fef46
+6 -3
View File
@@ -55,19 +55,22 @@ def load_freeimage():
try:
freeimage = loader.LoadLibrary(lib)
break
except Exception, e:
except Exception:
if lib not in bare_libs:
# Don't record errors when it couldn't load the library from
# a bare name -- this fails often, and doesn't provide any
# useful debugging information anyway, beyond "couldn't find
# library..."
errors.append((lib, e))
# Get exception instance in Python 2.x/3.x compatible manner
e_type, e_value, e_tb = sys.exc_info()
del e_tb
errors.append((lib, e_value))
if freeimage is None:
if errors:
# No freeimage library loaded, and load-errors reported for some
# candidate libs
err_txt = ['%s:\n%s'%(l, e.message) for l, e in errors]
err_txt = ['%s:\n%s'%(l, str(e.message)) for l, e in errors]
raise OSError('One or more FreeImage libraries were found, but '
'could not be loaded due to the following errors:\n'+
'\n\n'.join(err_txt))