Skip to content

Commit

Permalink
Fixes #4261
Browse files Browse the repository at this point in the history
SWIG_Python_str_AsChar and SWIG_Python_str_DelForPy3 are no longer available in swig 4.2 (see : swig/swig@f89dd59 ),
this commit fixes the build for swig versions > 4.2.
  • Loading branch information
kristofka authored and aothms committed Apr 21, 2024
1 parent fc5bb23 commit 589b980
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ifcwrap/utils/type_conversion.i
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,16 @@

template <>
std::string cast_pyobject(PyObject* element) {
#if SWIG_VERSION >= 0x040200
PyObject *pbytes = NULL;
const char* str_data = SWIG_PyUnicode_AsUTF8AndSize(element, NULL, &pbytes);
std::string str = str_data;
Py_XDECREF(pbytes);
#else
char* str_data = SWIG_Python_str_AsChar(element);
std::string str = str_data;
SWIG_Python_str_DelForPy3(str_data);
#endif
return str;
}

Expand Down

0 comments on commit 589b980

Please sign in to comment.