From d957a168b0c4ee7bba40d875dc073c9634252a08 Mon Sep 17 00:00:00 2001 From: Adrian Vladu Date: Fri, 3 Nov 2023 13:41:21 +0200 Subject: [PATCH] Add support for Python up to 3.12 PyMI already worked for Python up to 3.11 version. For Python 3.12, the deprecated PyUnicode_GetSize has been removed completely and needed to be updated with PyUnicode_GetLength. --- .github/workflows/pymi-cd.yml | 2 +- PyMI/Utils.cpp | 4 ++-- setup.cfg | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pymi-cd.yml b/.github/workflows/pymi-cd.yml index 6c742c7..6653132 100644 --- a/.github/workflows/pymi-cd.yml +++ b/.github/workflows/pymi-cd.yml @@ -9,7 +9,7 @@ jobs: strategy: max-parallel: 100 matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v1 diff --git a/PyMI/Utils.cpp b/PyMI/Utils.cpp index e988a4a..0588604 100644 --- a/PyMI/Utils.cpp +++ b/PyMI/Utils.cpp @@ -120,7 +120,7 @@ void GetIndexOrName(PyObject *item, std::wstring& name, Py_ssize_t& i) #endif if (PyUnicode_Check(item)) { - Py_ssize_t len = PyUnicode_GetSize(item) + 1; + Py_ssize_t len = PyUnicode_GetLength(item) + 1; wchar_t* w = new wchar_t[len]; if (PyUnicode_AsWideChar((PYUNICODEASVARCHARARG1TYPE*)item, w, len) < 0) @@ -143,7 +143,7 @@ void GetIndexOrName(PyObject *item, std::wstring& name, Py_ssize_t& i) std::wstring Py2WString(PyObject* pyValue) { - auto len = PyUnicode_GetSize(pyValue) + 1; + auto len = PyUnicode_GetLength(pyValue) + 1; wchar_t* w = new wchar_t[len]; if (PyUnicode_AsWideChar((PYUNICODEASVARCHARARG1TYPE*)pyValue, w, len) < 0) diff --git a/setup.cfg b/setup.cfg index e3313b5..9588fa1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,6 +15,11 @@ classifier = Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Environment :: Win32 (MS Windows) Intended Audience :: Developers Intended Audience :: System Administrators