From f6d97d2338c79490513637a46e2e2d9ec80b8707 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 31 Jan 2020 23:48:32 -0700 Subject: [PATCH] Use PyUnicode_AsUTF8() for Python >= 3.3 --- Lib/python/pyhead.swg | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index 9a55d76cf..b3bd39dfc 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -37,7 +37,9 @@ SWIGINTERN char* 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; str = PyUnicode_AsUTF8String(str); if (str) { @@ -56,10 +58,10 @@ SWIG_Python_str_AsChar(PyObject *str) #endif } -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#if PY_VERSION_HEX >= 0x03030000 || PY_VERSION_HEX < 0x03000000 +# define SWIG_Python_str_DelForPy3(x) #else -# define SWIG_Python_str_DelForPy3(x) +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) #endif