1. Marcus von Appen
  2. py-sdl2
  3. Issues
Issue #55 resolved

str/bytes issue in gamecontroller.py

created an issue

Loading game controller mappings from a file triggers a str/bytes error on Python 3:


results in

Traceback (most recent call last):
  File "D:\Code\pysdl2_tests\2_gamepad.py", line 80, in <module>
  File "D:\Code\pysdl2_tests\2_gamepad.py", line 49, in main
  File "./PySDL2\sdl2\gamecontroller.py", line 107, in <lambda>
    SDL_GameControllerAddMappingsFromFile = lambda fname: SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(fname, "rb"), 1)
ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type

To fix it, the "rb" argument to SDL_RWFromFile in gamecontroller.py, line 107, must be passed as a bytes object, i.e. using b"rb" or byteify("rb")

Comments (1)

  1. Log in to comment