Only in python3: autom4te.cache diff -urp '--exclude=*~' '--exclude=config.*' '--exclude=configure' '--exclude=Makefile' '--exclude=autom4te' python3.orig/configure.ac python3/configure.ac --- python3.orig/configure.ac 2023-01-02 12:09:13.189241055 +0900 +++ python3/configure.ac 2023-01-02 12:54:23.110443109 +0900 @@ -626,6 +626,7 @@ if test "$PYTHON" != "false"; then dnl DO NOT ASK WHY. I too can't explain. python_version=`(LANG=C ${PYTHON} --version 2>&1 | ${PERL} -e '$vin=<>;printf "python%s",substr($vin,7,rindex($vin,"\.",20)-7);')` AC_MSG_RESULT($python_version) + python3_minor=`(echo ${python_version} | sed -e 's|python3\.||')` python_config_bin=${python_version}-config python_configm_bin=${python_version}m-config python_configmu_bin=${python_version}mu-config @@ -650,6 +651,13 @@ if test "$PYTHON" != "false"; then dnl python 3.0, 3.1 & 3.2 are obsoleted and not supported if test "$enable_python3" = "yes";then + AC_MSG_CHECKING([whether python3 uses PEP 623]) + if test "$python3_minor" -ge 10 ; then + AC_MSG_RESULT([yes]) + python_define="$python_define -DUSE_PEP623" + else + AC_MSG_RESULT([yes]) + fi python_define="$python_define -DUSE_PEP393" fi diff -urp '--exclude=*~' '--exclude=config.*' '--exclude=configure' '--exclude=Makefile' '--exclude=autom4te' python3.orig/skf_convert.i python3/skf_convert.i --- python3.orig/skf_convert.i 2022-11-13 01:58:54.000000000 +0900 +++ python3/skf_convert.i 2023-01-02 14:05:06.713513508 +0900 @@ -106,10 +106,16 @@ const char *skf_notstring = "skf: not st #include "unicodeobject.h" #include "bytearrayobject.h" #define Py_SKFSTR PyObject -#ifdef USE_PEP393 /* after python 3.3 */ +#if defined (USE_PEP623) /* after python 3.10 */ +#define skf_PyUnicode_Srctype Py_UCS4 +#define skf_PyUnicode_GetSize(x) PyUnicode_GET_LENGTH(x) +#define skf_PyUnicode_AsUnicode(x) PyUnicode_AsUCS4Copy(x) +#elif defined (USE_PEP393) /* after python 3.3 */ +#define skf_PyUnicode_Srctype Py_UNICODE #define skf_PyUnicode_GetSize(x) PyUnicode_GET_LENGTH(x) #define skf_PyUnicode_AsUnicode(x) PyUnicode_AS_UNICODE(x) #else /* NOT PEP393 */ +#define skf_PyUnicode_Srctype Py_UNICODE #define skf_PyUnicode_GetSize PyUnicode_GETSIZE #define skf_PyUnicode_AsUnicode PyUnicode_AsUnicode #endif @@ -434,7 +440,7 @@ int c; char *skfstrstrconv(PyObject *robj,size_t len) { char *dstr; - Py_UNICODE *srcstr; + skf_PyUnicode_Srctype *srcstr = NULL; char *bsrcstr; Py_ssize_t slen; int i; @@ -467,6 +473,9 @@ char *skfstrstrconv(PyObject *robj,size_ if (srcstr[i] >= 0x7f) break; dstr[i] = srcstr[i]; }; +#if defined (USE_PEP623) + PyMem_Free(srcstr); +#endif } else if (PyByteArray_Check(robj)) { /* if SANE object */ if ((slen = PyByteArray_Size(robj)) <= 0) { return(NULL);