Merge pull request #1716 from ZackerySpytz/Python-utf8-cache

Use PyUnicode_AsUTF8() for Python >= 3.3
This commit is contained in:
William S Fulton 2020-05-29 23:56:10 +01:00 • committed by GitHub
commit 02e967d05d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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) ) # define SWIG_Python_str_DelForPy3(x)
#else #else
# define SWIG_Python_str_DelForPy3(x) # define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
#endif #endif