Skip to content

Commit

Permalink
Better error messages and tentative tests fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
itzpr3d4t0r committed Jan 5, 2025
1 parent c3122ec commit 1c9398b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src_c/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion test/font_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", ()),
Expand All @@ -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:
Expand Down

0 comments on commit 1c9398b

Please sign in to comment.