Skip to content

Commit aac9ad3

Browse files
committed
Text: fix for some python versions (3.0 <= PY_VERSION < 3.3)
1 parent 9b403f3 commit aac9ad3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

plugins/image/generator/Text/src/TextProcess.tcc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,21 @@ void TextProcess<View, Functor>::setup( const OFX::RenderArguments& args )
128128
//Get error message from python
129129
PyObject *ptype, *pvalue, *ptraceback;
130130
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
131-
char *pStrErrorMessage =
132131
#if PY_MAJOR_VERSION < 3
133-
PyString_AsString(pvalue);
132+
// Python version is < 3.0
133+
char *pStrErrorMessage = PyString_AsString(pvalue);
134+
#elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 3
135+
// PYTHON version is < 3.3
136+
PyObject* stringObj = PyUnicode_AsUTF8String(pvalue);
137+
char *pStrErrorMessage = PyBytes_AsString(stringObj);;
134138
#else
135-
PyUnicode_AsUTF8(pvalue);
139+
// PYTHON version is >= 3.3
140+
char *pStrErrorMessage = PyUnicode_AsUTF8(pvalue);
136141
#endif
137142
TUTTLE_LOG_ERROR("Python error : " << pStrErrorMessage);
143+
#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 3
144+
Py_DECREF(stringObj);
145+
#endif
138146

139147
_text = _params._text;
140148
}

0 commit comments

Comments
 (0)