From 04f5aee7c69b90f25f255bfa7a3025c4d96e7796 Mon Sep 17 00:00:00 2001 From: Jamie Bliss Date: Thu, 14 Dec 2023 22:21:24 -0500 Subject: [PATCH 1/2] Fix SDL error handling SDL error strings are only meaningful if SDL indicates an error --- ppb/systems/sdl_utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ppb/systems/sdl_utils.py b/ppb/systems/sdl_utils.py index a7017caa..83091e93 100644 --- a/ppb/systems/sdl_utils.py +++ b/ppb/systems/sdl_utils.py @@ -50,7 +50,7 @@ def sdl_call(func, *pargs, _check_error=None, **kwargs): SDL_ClearError() rv = func(*pargs, **kwargs) err = SDL_GetError() - if (_check_error(rv) if _check_error else err): + if _check_error is not None and _check_error(rv) : raise SdlError(f"Error calling {func.__name__}: {err.decode('utf-8')}") else: return rv @@ -90,8 +90,8 @@ def mix_call(func, *pargs, _check_error=None, **kwargs): Mix_SetError(b"") rv = func(*pargs, **kwargs) err = Mix_GetError() - if (_check_error(rv) if _check_error else err): - raise SdlMixerError(f"Error calling {func.__name__}: {err.decode('utf-8')}") + if _check_error is not None and _check_error(rv) : + raise SdlMixerError(f"Error calling {func.__name__}: {err.decode('utf-8')}") else: return rv @@ -113,7 +113,7 @@ def img_call(func, *pargs, _check_error=None, **kwargs): IMG_SetError(b"") rv = func(*pargs, **kwargs) err = IMG_GetError() - if (_check_error(rv) if _check_error else err): + if _check_error is not None and _check_error(rv) : raise SdlError(f"Error calling {func.__name__}: {err.decode('utf-8')}") else: return rv @@ -136,7 +136,7 @@ def ttf_call(func, *pargs, _check_error=None, **kwargs): TTF_SetError(b"") rv = func(*pargs, **kwargs) err = TTF_GetError() - if (_check_error(rv) if _check_error else err): + if _check_error is not None and _check_error(rv) : raise SdlError(f"Error calling {func.__name__}: {err.decode('utf-8')}") else: return rv From 932a772ce088e06051129012559e4cdcd34bcbae Mon Sep 17 00:00:00 2001 From: Jamie Bliss Date: Thu, 14 Dec 2023 22:21:40 -0500 Subject: [PATCH 2/2] Use pysdl2-dll on Linux --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 7a0976ea..65de967b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ PySDL2 -pysdl2-dll; sys.platform == 'win32' -pysdl2-dll; sys.platform == 'darwin' +pysdl2-dll ppb-vector ~= 1.0 Deprecated ~= 1.2.12 dataclasses; python_version < "3.7"