Use PyUnicode_AsUTF8() for Python >= 3.3

This commit is contained in:
Zackery Spytz 2020-01-31 23:48:32 -07:00
commit f6d97d2338

View file

@ -37,7 +37,9 @@
SWIGINTERN char* SWIGINTERN char*
SWIG_Python_str_AsChar(PyObject *str) SWIG_Python_str_AsChar(PyObject *str)
{ {
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03030000
return (char *)PyUnicode_AsUTF8(str);
#elif PY_VERSION_HEX >= 0x03000000
char *newstr = 0; char *newstr = 0;
str = PyUnicode_AsUTF8String(str); str = PyUnicode_AsUTF8String(str);
if (str) { if (str) {
@ -56,10 +58,10 @@ SWIG_Python_str_AsChar(PyObject *str)
#endif #endif
} }
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03030000 || PY_VERSION_HEX < 0x03000000
# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
#else
# define SWIG_Python_str_DelForPy3(x) # define SWIG_Python_str_DelForPy3(x)
#else
# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
#endif #endif