Skip to content

Commit bd018b1

Browse files
committed
[SQUASHME] Fix previous commit
1 parent 3a37183 commit bd018b1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/scorepy/pythonHelpers.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@ auto cast_to_PyFunc(TFunc* func) -> detail::ReplaceArgsToPyObject_t<TFunc>*
7575

7676
inline CString get_string_from_python(PyObject& o)
7777
{
78-
Py_ssize_t len;
7978
#if PY_MAJOR_VERSION >= 3
79+
Py_ssize_t len;
8080
const char* s = PyUnicode_AsUTF8AndSize(&o, &len);
81+
return CString(s, len);
8182
#else
82-
const char* s = PyString_FromStringAndSize(&o, &len);
83+
const char* s = PyString_AsString(&o);
84+
return CString(s);
8385
#endif
84-
return CString(s, len);
8586
}
8687

8788
/// Pair of a C-String and it's length useful for PyArg_ParseTuple with 's#'

0 commit comments

Comments
 (0)