Skip to content

Commit a62e7f3

Browse files
committed
Merge pull request #3545 from mdehoon/setfont_informative_error_message
MNT : Provide an informative error message if something goes wrong in setfont
1 parent 03ceef7 commit a62e7f3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/_macosx.m

+11-2
Original file line numberDiff line numberDiff line change
@@ -2531,14 +2531,23 @@ static CGFloat _get_device_scale(CGContextRef cr)
25312531
"CourierNewPS-Bold-ItalicMT"},
25322532
};
25332533

2534-
if(!PyList_Check(family)) return 0;
2534+
if(!PyList_Check(family))
2535+
{
2536+
PyErr_SetString(PyExc_ValueError, "family should be a list");
2537+
return 0;
2538+
}
25352539
n = PyList_GET_SIZE(family);
25362540

25372541
for (i = 0; i < n; i++)
25382542
{
25392543
PyObject* item = PyList_GET_ITEM(family, i);
25402544
ascii = PyUnicode_AsASCIIString(item);
2541-
if(!ascii) return 0;
2545+
if(!ascii)
2546+
{
2547+
PyErr_SetString(PyExc_ValueError,
2548+
"failed to convert font family name to ASCII");
2549+
return 0;
2550+
}
25422551
temp = PyBytes_AS_STRING(ascii);
25432552
for (j = 0; j < NMAP; j++)
25442553
{ if (!strcmp(map[j].name, temp))

0 commit comments

Comments
 (0)