diff --git a/skimage/io/_plugins/freeimage_plugin.py b/skimage/io/_plugins/freeimage_plugin.py index e78d5d4a..5d023909 100644 --- a/skimage/io/_plugins/freeimage_plugin.py +++ b/skimage/io/_plugins/freeimage_plugin.py @@ -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))