pyodbc icon indicating copy to clipboard operation
pyodbc copied to clipboard

Deprecated PyUnicode functions that must be updated

Open keitherskine opened this issue 3 years ago • 5 comments

I just wanted to create this issue as a placeholder for certain c-extension functions used by pyodbc that are going to be removed in upcoming Python versions. Here is the list I have so far:

To be removed in version 3.11: PyUnicode_EncodeUTF8 PyUnicode_EncodeUTF16

To be removed in version 3.12: PyUnicode_GET_SIZE PyUnicode_AS_UNICODE PyUnicode_AS_DATA PyUnicode_FromStringAndSize PyUnicode_FromUnicode PyUnicode_GetSize PyUnicode_FromObject

Ref: https://docs.python.org/3/c-api/unicode.html https://docs.python.org/3/c-api/call.html

keitherskine avatar Jun 20 '21 22:06 keitherskine

There is one PR #792 that has made a start on converting the relevant code to the preferred functions.

keitherskine avatar Jun 20 '21 22:06 keitherskine

I saw the PR - great job. I left a question on one part.

This may be the first item for v5 *(#945).

mkleehammer avatar Aug 22 '21 20:08 mkleehammer

@mkleehammer Under Python 3.10 PyUnicode_FromUnicode(NULL, size) triggers a DeprecationWarning message to stderr, breaking CGI scripts. Should I open a separate ticket to get this fixed on a faster track than #945? To reproduce (pyodbc-4.0.32):

...
rows = cursor.fetchall()
logstring = repr(rows)

(Also, GitHub is somehow suppressing the comment you said you left on #792.)

bkline avatar Dec 27 '21 11:12 bkline

What's the status of this now that #792 has been merged?

gordthompson avatar Aug 04 '22 22:08 gordthompson

There are still plenty of deprecated functions that are causing warning messages during builds. Until the Python 3.12 deprecated functions are replaced in the code, this issue still stands.

keitherskine avatar Aug 04 '22 23:08 keitherskine

Fedora rawhide now has Python 3.12 and so pyodbc is failing to build. Any progress on this issue?

opoplawski avatar Jul 18 '23 02:07 opoplawski

Well, the py3 branch builds on Python 3.12 on Ubuntu, without fast_execute_many, and works with the PostgreSQL unit tests.

My conversion task list of this topic has a bunch of unchecked items, but I actually think they are done. One difficultly with any PRs, is that the py3 branch is quite different from the production branch for now.

mkleehammer avatar Aug 22 '23 00:08 mkleehammer

I've merged 5.0 with Python 3.12 support into the master branch and published 5.0.0 alpha2. I'll make a final release of 5.0.0 in the next few days if no serious problems are found.

See the discussion here

mkleehammer avatar Aug 26 '23 21:08 mkleehammer