1. Marcus von Appen
  2. py-sdl2

Commits

Marcus von Appen  committed c8658e8

- fixed issue #14: DLL error messages on import should be improved now

  • Participants
  • Parent commits e3af79b
  • Branches default

Comments (0)

Files changed (1)

File sdl2/dll.py

View file
  • Ignore whitespace
     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)
                 # 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"])
             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" %