We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3a37183 commit bd018b1Copy full SHA for bd018b1
1 file changed
src/scorepy/pythonHelpers.hpp
@@ -75,13 +75,14 @@ auto cast_to_PyFunc(TFunc* func) -> detail::ReplaceArgsToPyObject_t<TFunc>*
75
76
inline CString get_string_from_python(PyObject& o)
77
{
78
- Py_ssize_t len;
79
#if PY_MAJOR_VERSION >= 3
+ Py_ssize_t len;
80
const char* s = PyUnicode_AsUTF8AndSize(&o, &len);
81
+ return CString(s, len);
82
#else
- const char* s = PyString_FromStringAndSize(&o, &len);
83
+ const char* s = PyString_AsString(&o);
84
+ return CString(s);
85
#endif
- return CString(s, len);
86
}
87
88
/// Pair of a C-String and it's length useful for PyArg_ParseTuple with 's#'
0 commit comments