mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.92k stars 563 forks source link

Replace deprecated PyUnicode_FromUnicode(NULL, size) calls (#998) #999

Closed bkline closed 2 years ago

bkline commented 2 years ago

Current versions of Python write a deprecation warning message to stderr, which breaks CGI scripts running under web servers which fold stderr into stdout. Likely breaks other software. This change replaces the deprecated calls with PyUnicode_New(size, 0x10ffff). The second argument represents the highest code point for Unicode characters, which is used because the calls being replaced have no string value from which we can determine the smallest number of bytes needed to represent any value which can be stored in the newly-created object.

Fixes #998

bkline commented 2 years ago

I have included a unit test, but I assume others more familiar with the project will want to decide how to integrate it with the existing tests. I didn't fold the test in with any of the other sets, because the only sets in tests3 which were not DBMS-specific were for tests of the API, and this isn't a fix of API behavior (or rather, it's a fix of internals related to working with the Python APIs). The test fails without the fix and passes with it.

bkline commented 2 years ago

Reaching out in the ticket for assistance.

bkline commented 2 years ago

Going to get another running start on this one.