$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>)
-INSTALL(TARGETS py2cpp EXPORT FindPy2cpp LIBRARY DESTINATION lib)
+INSTALL(TARGETS py2cpp EXPORT Py2cppCfg LIBRARY DESTINATION lib)
INSTALL(FILES ${_py2cpp_headers} DESTINATION include/py2cpp)
-INSTALL(EXPORT FindPy2cpp DESTINATION lib/cmake/py2cpp)
+INSTALL(EXPORT Py2cppCfg DESTINATION lib/cmake/py2cpp FILE Py2cppConfig.cmake)
ADD_SUBDIRECTORY(Test)
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
PyErr_NormalizeException(&ptype, &pvalue, &ptraceback);
pystr = PyObject_Str(pvalue);
- result = std::string(PyUnicode_AsUTF8(pystr));
+ const char* charstr = PyUnicode_AsUTF8(pystr);
+ if(charstr != nullptr)
+ result = std::string(charstr);
result += "\n";
Py_DECREF(pystr);
for(int i=0; i<n; i++)
{
pystr = PyList_GetItem(pyList,i);
- result += std::string(PyUnicode_AsUTF8(pystr));
+ const char* charstr = PyUnicode_AsUTF8(pystr);
+ if(charstr != nullptr)
+ result += charstr;
}
Py_DECREF(pyList);
}
std::string pyRepr;
PyObject* pyResult = PyObject_Repr(obj);
if(pyResult && PyUnicode_Check(pyResult))
- pyRepr = PyUnicode_AsUTF8(pyResult);
+ {
+ const char* charstr = PyUnicode_AsUTF8(pyResult);
+ if(charstr != nullptr)
+ pyRepr = charstr;
+ }
else
pyRepr = "unknown representation";
Py_XDECREF(pyResult);
{
PyObject* pyResult = PyObject_Repr(thisObj);
if(pyResult && PyUnicode_Check(pyResult))
- result = PyUnicode_AsUTF8(pyResult);
+ {
+ const char* charstr = PyUnicode_AsUTF8(pyResult);
+ if(charstr != nullptr)
+ result = charstr;
+ }
Py_XDECREF(pyResult);
}
return result;
{
ConversionCheck check;
if(po && PyUnicode_Check(po))
- result = PyUnicode_AsUTF8(po);
+ {
+ const char* charstr = PyUnicode_AsUTF8(po);
+ if(charstr != nullptr)
+ result = charstr;
+ else
+ result = "";
+ }
else
check.addError("std::string", po);
return check;