104 lines
3.8 KiB
Diff
104 lines
3.8 KiB
Diff
From 3a8a947e41ae1cd5fb109fe07f85a4299ff5a77a Mon Sep 17 00:00:00 2001
|
|
From: Inada Naoki <songofacandy@gmail.com>
|
|
Date: Mon, 29 Jun 2020 10:56:38 +0900
|
|
Subject: [PATCH 1/3] Use PyUnicode_AsUTF8String
|
|
|
|
PyUnicode_EncodeUTF8 is deprecated, and PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(p), ...) is inefficient.
|
|
---
|
|
src/cnxninfo.cpp | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/src/cnxninfo.cpp b/src/cnxninfo.cpp
|
|
index 9934feec..99ce33bd 100644
|
|
--- a/src/cnxninfo.cpp
|
|
+++ b/src/cnxninfo.cpp
|
|
@@ -42,7 +42,7 @@ bool CnxnInfo_init()
|
|
static PyObject* GetHash(PyObject* p)
|
|
{
|
|
#if PY_MAJOR_VERSION >= 3
|
|
- Object bytes(PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(p), PyUnicode_GET_SIZE(p), 0));
|
|
+ Object bytes(PyUnicode_AsUTF8String(p));
|
|
if (!bytes)
|
|
return 0;
|
|
p = bytes.Get();
|
|
|
|
From 09864fb7a39ed81d6d0c360ffd796e858e1197d5 Mon Sep 17 00:00:00 2001
|
|
From: Inada Naoki <songofacandy@gmail.com>
|
|
Date: Sun, 5 Jul 2020 16:06:48 +0900
|
|
Subject: [PATCH 2/3] Fix ExecuteMulti too
|
|
|
|
---
|
|
src/params.cpp | 24 +++++++++++++++++++++---
|
|
1 file changed, 21 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/params.cpp b/src/params.cpp
|
|
index 20548c2d..108ba02f 100644
|
|
--- a/src/params.cpp
|
|
+++ b/src/params.cpp
|
|
@@ -1921,9 +1921,10 @@ bool ExecuteMulti(Cursor* cur, PyObject* pSql, PyObject* paramArrayObj)
|
|
if (PyUnicode_Check(objCell))
|
|
{
|
|
const TextEnc& enc = cur->cnxn->sqlwchar_enc;
|
|
- int cb = PyUnicode_GET_DATA_SIZE(objCell) / 2;
|
|
-
|
|
PyObject* bytes = NULL;
|
|
+
|
|
+#if PY_MAJOR_VERSION < 3
|
|
+ int cb = PyUnicode_GET_DATA_SIZE(objCell) / 2;
|
|
const Py_UNICODE* source = PyUnicode_AS_UNICODE(objCell);
|
|
|
|
switch (enc.optenc)
|
|
@@ -1941,11 +1942,28 @@ bool ExecuteMulti(Cursor* cur, PyObject* pSql, PyObject* paramArrayObj)
|
|
bytes = PyUnicode_EncodeUTF16(source, cb, "strict", BYTEORDER_BE);
|
|
break;
|
|
}
|
|
-
|
|
+#else
|
|
+ switch (enc.optenc)
|
|
+ {
|
|
+ case OPTENC_UTF8:
|
|
+ bytes = PyUnicode_AsUTF8String(objCell);
|
|
+ break;
|
|
+ case OPTENC_UTF16:
|
|
+ bytes = PyUnicode_AsUTF16String(objCell);
|
|
+ break;
|
|
+ case OPTENC_UTF16LE:
|
|
+ bytes = PyUnicode_AsEncodedString(objCell, "utf_16_le", NULL);
|
|
+ break;
|
|
+ case OPTENC_UTF16BE:
|
|
+ bytes = PyUnicode_AsEncodedString(objCell, "utf_16_be", NULL);
|
|
+ break;
|
|
+ }
|
|
+#endif
|
|
if (bytes && PyBytes_Check(bytes))
|
|
{
|
|
objCell = bytes;
|
|
}
|
|
+ //TODO: Raise or clear error when bytes == NULL.
|
|
}
|
|
|
|
szLastFunction = "SQLPutData";
|
|
|
|
From 8b0aaf0d8c001c1baad229259805f7d5a85b4aad Mon Sep 17 00:00:00 2001
|
|
From: Keith Erskine <toastie604@gmail.com>
|
|
Date: Sat, 5 Feb 2022 19:18:24 -0600
|
|
Subject: [PATCH 3/3] benign commit to trigger build tests
|
|
|
|
---
|
|
src/errors.h | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/src/errors.h b/src/errors.h
|
|
index 771c2696..6ce8d79d 100644
|
|
--- a/src/errors.h
|
|
+++ b/src/errors.h
|
|
@@ -61,7 +61,7 @@ inline PyObject* RaiseErrorFromException(PyObject* pError)
|
|
#if PY_MAJOR_VERSION >= 3
|
|
PyErr_SetObject((PyObject*)Py_TYPE(pError), pError);
|
|
#else
|
|
- PyObject* cls = (PyObject*)((PyInstance_Check(pError) ? (PyObject*)((PyInstanceObject*)pError)->in_class : (PyObject*)(Py_TYPE(pError))));
|
|
+ PyObject* cls = (PyObject*)((PyInstance_Check(pError) ? (PyObject*)((PyInstanceObject*)pError)->in_class : (PyObject*)(Py_TYPE(pError))));
|
|
PyErr_SetObject(cls, pError);
|
|
#endif
|
|
return 0;
|