Skip to content

Commit f0420c4

Browse files
committed
Better error messages and tentative tests fix?
1 parent 27f46c5 commit f0420c4

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src_c/font.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,12 @@ font_set_linesize(PyObject *self, PyObject *arg)
215215
#if SDL_TTF_VERSION_ATLEAST(2, 24, 0)
216216
TTF_Font *font = PyFont_AsFont(self);
217217
int linesize = PyLong_AsLong(arg);
218-
if (linesize < 0 || PyErr_Occurred()) {
218+
if (PyErr_Occurred())
219+
return NULL;
220+
221+
if (linesize < 0)
219222
return RAISE(PyExc_ValueError, "linesize must be >= 0");
220-
}
223+
221224
TTF_SetFontLineSkip(font, linesize);
222225

223226
Py_RETURN_NONE;

test/font_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,6 @@ def test_font_method_should_raise_exception_after_quit(self):
901901
("get_descent", ()),
902902
("get_ascent", ()),
903903
("get_linesize", ()),
904-
("set_linesize", (2,)),
905904
("get_bold", ()),
906905
("set_bold", (True,)),
907906
("get_italic", ()),
@@ -919,6 +918,11 @@ def test_font_method_should_raise_exception_after_quit(self):
919918
skip_methods = set()
920919
version = pygame.font.get_sdl_ttf_version()
921920
if version >= (2, 0, 18):
921+
if version >= (2, 24, 0):
922+
methods.append(("set_linesize", (2,)))
923+
else:
924+
skip_methods.add("set_linesize")
925+
922926
methods.append(("get_point_size", ()))
923927
methods.append(("set_point_size", (34,)))
924928
else:

0 commit comments

Comments
 (0)