Python: deal with Qt5 compatibility

QDebug can't log std::string in Qt5, it seems
This commit is contained in:
Adriaan de Groot 2023-09-12 19:27:43 +02:00
parent 0468ff400b
commit 24de6b69c4

View File

@ -24,9 +24,13 @@
#include <string> #include <string>
inline QDebug& inline QDebug&
operator<<( QDebug& s, const pybind11::handle & h ) operator<<( QDebug& s, const pybind11::handle& h )
{ {
return s << pybind11::str(h).cast<std::string>(); #if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
return s << QString::fromUtf8( pybind11::str( h ).cast< std::string >().c_str() );
#else
return s << pybind11::str( h ).cast< std::string >();
#endif
} }
#endif #endif