changeset 103:c8658e86295d

- fixed issue #14: DLL error messages on import should be improved now
author Marcus von Appen <marcus@sysfault.org>
date Fri, 06 Sep 2013 20:25:43 +0200
parents e3af79b02776
children ef55e76a406d
files sdl2/dll.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/sdl2/dll.py	Wed Sep 04 19:06:52 2013 -0300
+++ b/sdl2/dll.py	Fri Sep 06 20:25:43 2013 +0200
@@ -46,8 +46,10 @@
     def __init__(self, libinfo, libnames, path=None):
         self._dll = None
         foundlibs = _findlib(libnames, path)
+        dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
         if len(foundlibs) == 0:
-            raise RuntimeError("could not find any library for %s" % libinfo)
+            raise RuntimeError("could not find any library for %s (%s)" %
+                               (libinfo, dllmsg))
         for libfile in foundlibs:
             try:
                 self._dll = CDLL(libfile)
@@ -58,7 +60,8 @@
                 # to the next one.
                 warnings.warn(repr(exc), ImportWarning)
         if self._dll is None:
-            raise RuntimeError("could not load any library for %s" % libinfo)
+            raise RuntimeError("found %s, but it's not usable for the libary %s" %
+                               (foundlibs, libinfo))
         if path is not None and sys.platform in ("win32", "cli") and \
             path in self._libfile:
             os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
@@ -71,7 +74,7 @@
             if optfunc:
                 warnings.warn\
                     ("function '%s' not found in %r, using replacement" %
-                     (funcname, self._dll))
+                     (funcname, self._dll), ImportWarning)
                 func = _nonexistent(funcname, optfunc)
             else:
                 raise ValueError("could not find function '%s' in %r" %