From 1c9398b18f1783b3cd1363dade1eeea97f70ca82 Mon Sep 17 00:00:00 2001 From: itzpr3d4t0r <103119829+itzpr3d4t0r@users.noreply.github.com> Date: Sun, 5 Jan 2025 14:14:52 +0100 Subject: [PATCH] Better error messages and tentative tests fix? --- src_c/font.c | 7 +++++-- test/font_test.py | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src_c/font.c b/src_c/font.c index 3758825d1f..daaf97ff55 100644 --- a/src_c/font.c +++ b/src_c/font.c @@ -215,9 +215,12 @@ font_set_linesize(PyObject *self, PyObject *arg) #if SDL_TTF_VERSION_ATLEAST(2, 24, 0) TTF_Font *font = PyFont_AsFont(self); int linesize = PyLong_AsLong(arg); - if (linesize < 0 || PyErr_Occurred()) { + if (PyErr_Occurred()) + return NULL; + + if (linesize < 0) return RAISE(PyExc_ValueError, "linesize must be >= 0"); - } + TTF_SetFontLineSkip(font, linesize); Py_RETURN_NONE; diff --git a/test/font_test.py b/test/font_test.py index cb613d494d..ef8762b3fc 100644 --- a/test/font_test.py +++ b/test/font_test.py @@ -901,7 +901,6 @@ def test_font_method_should_raise_exception_after_quit(self): ("get_descent", ()), ("get_ascent", ()), ("get_linesize", ()), - ("set_linesize", (2,)), ("get_bold", ()), ("set_bold", (True,)), ("get_italic", ()), @@ -919,6 +918,11 @@ def test_font_method_should_raise_exception_after_quit(self): skip_methods = set() version = pygame.font.get_sdl_ttf_version() if version >= (2, 0, 18): + if version >= (2, 24, 0): + methods.append(("set_linesize", (2,))) + else: + skip_methods.add("set_linesize") + methods.append(("get_point_size", ())) methods.append(("set_point_size", (34,))) else: