diff --git a/src/ft2font_wrapper.cpp b/src/ft2font_wrapper.cpp index c0e2a20a1a12..300b37ce6417 100644 --- a/src/ft2font_wrapper.cpp +++ b/src/ft2font_wrapper.cpp @@ -297,6 +297,8 @@ static unsigned long read_from_file_callback(FT_Stream stream, static void close_file_callback(FT_Stream stream) { + PyObject *type, *value, *traceback; + PyErr_Fetch(&type, &value, &traceback); PyFT2Font *self = (PyFT2Font *)stream->descriptor.pointer; PyObject *close_result = NULL; if (!(close_result = PyObject_CallMethod(self->py_file, "close", ""))) { @@ -308,6 +310,7 @@ static void close_file_callback(FT_Stream stream) if (PyErr_Occurred()) { PyErr_WriteUnraisable((PyObject*)self); } + PyErr_Restore(type, value, traceback); } static PyTypeObject PyFT2FontType;