Improving DLL error messages

Issue #14 resolved
Roger Flores
created an issue

I installed the 64 bit sdl2 DLLs for my Win 7 x64 OS. Running (draw.py) reported

ImportError: could not load any library for SDL2

After some tracking, I figured out the Python was 32 bit, which can't use 64 bit libs. Specifically, exc at dll.py:57 is "[Error 193] %1 is not a valid Win32 application", raised from CDLL().

The import feedback could be more helpful. Mentioning that a dll file was found but not usable/suitable makes it clear that path issues aren't the source of the problem. So change dll.py:61 to raise RuntimeError("found %s but it's not usable for the libary %s" % (foundlibs, libinfo))

dll.py:50 could become: raise RuntimeError("searched %s but could not find any library for %s" % (path, libinfo))

It would also help to mention PYSDL2_DLL_PATH when there's a problem and it's unset so that people know about it.
dll.py:101: if os.getenv("PYSDL2_DLL_PATH") == None: exc = exc.message + " (and PYSDL2_DLL_PATH is unset)";

Comments (1)

  1. Log in to comment