diff --git a/python-PySDL2.changes b/python-PySDL2.changes index 12e4829..2e78733 100644 --- a/python-PySDL2.changes +++ b/python-PySDL2.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Jan 21 11:12:54 UTC 2026 - Markéta Machová + +- Add upstream PRs fixing test failures: + * surface_test.patch + * video_test.patch + ------------------------------------------------------------------- Wed Apr 30 00:41:39 UTC 2025 - Jan Engelhardt diff --git a/python-PySDL2.spec b/python-PySDL2.spec index 50f2de2..6d72a12 100644 --- a/python-PySDL2.spec +++ b/python-PySDL2.spec @@ -1,7 +1,7 @@ # # spec file for package python-PySDL2 # -# Copyright (c) 2025 SUSE LLC +# Copyright (c) 2026 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -25,6 +25,10 @@ Summary: Python ctypes wrapper around SDL2 License: SUSE-Public-Domain URL: https://github.com/py-sdl/py-sdl2 Source: https://files.pythonhosted.org/packages/source/p/%{lname}/%{lname}-%{version}.tar.gz +# PATCH-FIX-UPSTREAM https://github.com/py-sdl/py-sdl2/pull/290 surface_test: Expect intended behaviour if SDL2 is new enough +Patch0: surface_test.patch +# PATCH-FIX-UPSTREAM https://github.com/py-sdl/py-sdl2/pull/291 video_test: Skip SDL_SetWindowMouseRect with sdl2-compat dummy driver +Patch1: video_test.patch BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} BuildRequires: %{python_module wheel} diff --git a/surface_test.patch b/surface_test.patch new file mode 100644 index 0000000..a47f4fb --- /dev/null +++ b/surface_test.patch @@ -0,0 +1,66 @@ +From a9163d3c134f22add5d672d11d2e2e1ae07e58f1 Mon Sep 17 00:00:00 2001 +From: Simon McVittie +Date: Fri, 19 Dec 2025 17:58:01 +0000 +Subject: [PATCH] surface_test: Expect intended behaviour if SDL2 is new enough + +In older versions of "classic" SDL2, including the 2.32.x series, +intersecting an empty rectangle with another rectangle would have an +empty result (w=0, h=0) with an uninitialized position (x, y arbitrary). +However, SDL upstream considers this to be a bug, and it caused +observable visual issues in some older games when used in conjunction +with sdl12-compat. + +This test previously asserted that the clip rectangle would not be equal +to the requested clip rectangle, but that was only true because of +this bug: the uninitialized x and y coordinates were very unlikely to be +equal to the requested rectangle. With the bug fix in sdl2-compat, +the coordinates come out as equal to those that were requested. + +If SDL2 is sufficiently new, assert that the comparison result is true +(which is the correct result according to SDL upstream), and if not, +make no assertion (in case the bug fix is backported). + +Resolves: https://github.com/py-sdl/py-sdl2/issues/289 +Signed-off-by: Simon McVittie +--- + sdl2/test/surface_test.py | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +diff --git a/sdl2/test/surface_test.py b/sdl2/test/surface_test.py +index e8740e8..f241846 100644 +--- a/sdl2/test/surface_test.py ++++ b/sdl2/test/surface_test.py +@@ -467,13 +467,20 @@ def test_SDL_FreeSurface(self): + sdl2.SDL_FreeSurface(sf) + + def test_SDL_GetSetClipRect(self): ++ # A bug in intersecting empty rectangles was fixed in SDL2 2.33.x ++ # and in sdl2-compat (which reports its version as >= 2.32.50) ++ if sdl2.dll.version_tuple >= (2, 32, 50): ++ true_if_fixed = True ++ else: ++ true_if_fixed = None ++ + rectlist = ((rect.SDL_Rect(0, 0, 0, 0), SDL_FALSE, True), +- (rect.SDL_Rect(2, 2, 0, 0), SDL_FALSE, False), ++ (rect.SDL_Rect(2, 2, 0, 0), SDL_FALSE, true_if_fixed), + (rect.SDL_Rect(2, 2, 5, 1), SDL_TRUE, True), + (rect.SDL_Rect(6, 5, 10, 3), SDL_TRUE, False), + (rect.SDL_Rect(0, 0, 10, 10), SDL_TRUE, True), +- (rect.SDL_Rect(0, 0, -10, 10), SDL_FALSE, False), +- (rect.SDL_Rect(0, 0, -10, -10), SDL_FALSE, False), ++ (rect.SDL_Rect(0, 0, -10, 10), SDL_FALSE, true_if_fixed), ++ (rect.SDL_Rect(0, 0, -10, -10), SDL_FALSE, true_if_fixed), + (rect.SDL_Rect(-10, -10, 10, 10), SDL_FALSE, False), + (rect.SDL_Rect(10, -10, 10, 10), SDL_FALSE, False), + (rect.SDL_Rect(10, 10, 10, 10), SDL_TRUE, False) +@@ -490,7 +497,8 @@ def test_SDL_GetSetClipRect(self): + sdl2.SDL_GetClipRect(sf, byref(clip)) + err = "Could not set clip rect %s" % r + assert retval == clipsetval, "retval: " + err +- assert (clip == r) == cmpval, "clip: " + err ++ if cmpval is not None: ++ assert (clip == r) == cmpval, "clip: " + err + sdl2.SDL_FreeSurface(sf) + + def test_SDL_GetSetSurfaceAlphaMod(self): diff --git a/video_test.patch b/video_test.patch new file mode 100644 index 0000000..7aca5c2 --- /dev/null +++ b/video_test.patch @@ -0,0 +1,25 @@ +From 96ba83b67daac9d45efb5e5d7d4c904aee8446ac Mon Sep 17 00:00:00 2001 +From: Simon McVittie +Date: Fri, 19 Dec 2025 18:07:02 +0000 +Subject: [PATCH] video_test: Skip SDL_SetWindowMouseRect with sdl2-compat + dummy driver + +This driver doesn't implement mouse confinement. + +Signed-off-by: Simon McVittie +--- + sdl2/test/video_test.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/sdl2/test/video_test.py b/sdl2/test/video_test.py +index 0b8801f..a216906 100644 +--- a/sdl2/test/video_test.py ++++ b/sdl2/test/video_test.py +@@ -730,6 +730,7 @@ def test_SDL_GetGrabbedWindow(window): + # NOTE: Should implement this once the above tests are fixed + pass + ++@pytest.mark.skipif(DRIVER_DUMMY, reason="Not implemented by dummy driver") + @pytest.mark.skipif(sdl2.dll.version < 2018, reason="not available") + def test_SDL_GetSetWindowMouseRect(with_sdl): + flags = sdl2.SDL_WINDOW_BORDERLESS