Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85b3470

Browse files
committed
Merge pull request matplotlib#2991 from jkseppan/tidyup-ft2font
Silence some compiler warnings related to ft2font
2 parents eb7fd2a + 0c0ff8b commit 85b3470

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/file_compat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,15 @@ mpl_PyFile_OpenFile(PyObject *filename, const char *mode)
192192
if (open == NULL) {
193193
return NULL;
194194
}
195-
return PyObject_CallFunction(open, "Os", filename, mode);
195+
return PyObject_CallFunction(open, (char*)"Os", filename, mode);
196196
}
197197

198198
static NPY_INLINE int
199199
mpl_PyFile_CloseFile(PyObject *file)
200200
{
201201
PyObject *ret;
202202

203-
ret = PyObject_CallMethod(file, "close", NULL);
203+
ret = PyObject_CallMethod(file, (char*)"close", NULL);
204204
if (ret == NULL) {
205205
return -1;
206206
}

src/ft2font.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ FT2Image::py_write_bitmap(const Py::Tuple & args)
193193

194194
write_bitmap(fh);
195195

196-
mpl_PyFile_DupClose(py_file, fh, offset);
196+
if (mpl_PyFile_DupClose(py_file, fh, offset))
197+
{
198+
throw Py::Exception();
199+
}
197200
mpl_PyFile_CloseFile(py_file);
198201
Py_DECREF(py_file);
199202

@@ -2143,7 +2146,10 @@ static void close_file_callback(FT_Stream stream)
21432146
{
21442147
py_file_def *def = (py_file_def *)stream->descriptor.pointer;
21452148

2146-
mpl_PyFile_DupClose(def->py_file, def->fp, def->offset);
2149+
if (mpl_PyFile_DupClose(def->py_file, def->fp, def->offset))
2150+
{
2151+
throw Py::Exception();
2152+
}
21472153

21482154
if (def->close_file) {
21492155
mpl_PyFile_CloseFile(def->py_file);
@@ -2165,7 +2171,7 @@ FT2Font::make_open_args(PyObject *py_file_arg, FT_Open_Args *open_args)
21652171
py_file_def *stream_info = NULL;
21662172
long file_size;
21672173
FT_Byte *new_memory;
2168-
mpl_off_t offset;
2174+
mpl_off_t offset = 0;
21692175

21702176
int result = -1;
21712177

@@ -2208,7 +2214,7 @@ FT2Font::make_open_args(PyObject *py_file_arg, FT_Open_Args *open_args)
22082214
open_args->stream = &stream;
22092215
} else {
22102216
if (PyObject_HasAttrString(py_file_arg, "read") &&
2211-
(data = PyObject_CallMethod(py_file_arg, "read", ""))) {
2217+
(data = PyObject_CallMethod(py_file_arg, (char*)"read", (char*)""))) {
22122218
if (PyBytes_AsStringAndSize(data, &data_ptr, &data_len)) {
22132219
goto exit;
22142220
}

0 commit comments

Comments
 (0)