-
Notifications
You must be signed in to change notification settings - Fork 567
Closed
Description
Environment
- Python: 3.10.1
- pyodbc: 4.0.32
- OS: Any
- DB: Any
- driver: Any
Issue
Under Python 3.10 PyUnicode_FromUnicode(NULL, size)
triggers a DeprecationWarning
message to stderr
, breaking CGI scripts. To reproduce:
#!/usr/bin/env python3
"""Repro case to demonstrate deprecation warning.
Breaks CGI scripts.
"""
from argparse import ArgumentParser
from pyodbc import connect # pylint: disable=no-name-in-module
parser = ArgumentParser()
parser.add_argument("--connection-string", "-c", required=True)
opts = parser.parse_args()
conn = connect(opts.connection_string)
cursor = conn.cursor()
cursor.execute("SELECT 1 AS a, 2 AS b")
rows = cursor.fetchall()
print(f"""\
Content-type: text/plain
HTTP header(s) should be first in the output, but they're not. :(
{rows!r}""")
Expected Output
Content-type: text/plain
HTTP header(s) should be first in the output, but they're not. :(
[(1, 2)]
Actual Output
/Users/bkline/gdrive/Notes/Python/./pyodbcrepro.py:18: DeprecationWarning: PyUnicode_FromUnicode(NULL, size) is deprecated; use PyUnicode_New() instead
print(f"""\
Content-type: text/plain
HTTP header(s) should be first in the output, but they're not. :(
[(1, 2)]
Metadata
Metadata
Assignees
Labels
No labels