Skip to content

Commit f6d97d2

Browse files
committed
Use PyUnicode_AsUTF8() for Python >= 3.3
1 parent a973125 commit f6d97d2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Lib/python/pyhead.swg

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
SWIGINTERN char*
3838
SWIG_Python_str_AsChar(PyObject *str)
3939
{
40-
#if PY_VERSION_HEX >= 0x03000000
40+
#if PY_VERSION_HEX >= 0x03030000
41+
return (char *)PyUnicode_AsUTF8(str);
42+
#elif PY_VERSION_HEX >= 0x03000000
4143
char *newstr = 0;
4244
str = PyUnicode_AsUTF8String(str);
4345
if (str) {
@@ -56,10 +58,10 @@ SWIG_Python_str_AsChar(PyObject *str)
5658
#endif
5759
}
5860

59-
#if PY_VERSION_HEX >= 0x03000000
60-
# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
61+
#if PY_VERSION_HEX >= 0x03030000 || PY_VERSION_HEX < 0x03000000
62+
# define SWIG_Python_str_DelForPy3(x)
6163
#else
62-
# define SWIG_Python_str_DelForPy3(x)
64+
# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
6365
#endif
6466

6567

0 commit comments

Comments
 (0)