str/bytes issue in

Issue #55 resolved
arifsch 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\", line 80, in <module>
  File "D:\Code\pysdl2_tests\", line 49, in main
  File "./PySDL2\sdl2\", 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, line 107, must be passed as a bytes object, i.e. using b"rb" or byteify("rb")

Comments (1)

  1. Log in to comment