Skip to content

Commit

Permalink
Add support for Python up to 3.12
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ader1990 committed Nov 3, 2023
1 parent 899dce4 commit d957a16
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pymi-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions PyMI/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d957a16

Please sign in to comment.