pyodbc: use WORDS_BIGENDIAN instead of OS-specific defines
Python provides the WORDS_BIGENDIAN macro, use it to figure out the native endian of the host. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
parent
47ce2f94af
commit
7a2623d12d
2 changed files with 5 additions and 6 deletions
|
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=pyodbc
|
PKG_NAME:=pyodbc
|
||||||
PKG_VERSION:=4.0.17
|
PKG_VERSION:=4.0.17
|
||||||
PKG_RELEASE:=4
|
PKG_RELEASE:=5
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=https://pypi.python.org/packages/ce/57/6b92aa5b3497dde6be55fd6fcb76c7db215ed1d56fde45c613add4a43095/
|
PKG_SOURCE_URL:=https://pypi.python.org/packages/ce/57/6b92aa5b3497dde6be55fd6fcb76c7db215ed1d56fde45c613add4a43095/
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
--- a/src/connection.cpp
|
--- a/src/connection.cpp
|
||||||
+++ b/src/connection.cpp
|
+++ b/src/connection.cpp
|
||||||
@@ -18,6 +18,15 @@
|
@@ -18,6 +18,14 @@
|
||||||
#include "cnxninfo.h"
|
#include "cnxninfo.h"
|
||||||
#include "sqlwchar.h"
|
#include "sqlwchar.h"
|
||||||
|
|
||||||
+#include <endian.h>
|
+#ifdef WORDS_BIGENDIAN
|
||||||
+#if __BYTE_ORDER == __BIG_ENDIAN
|
|
||||||
+# define OPTENC_UTF16NE OPTENC_UTF16BE
|
+# define OPTENC_UTF16NE OPTENC_UTF16BE
|
||||||
+# define ENCSTR_UTF16NE "utf-16be"
|
+# define ENCSTR_UTF16NE "utf-16be"
|
||||||
+#else
|
+#else
|
||||||
|
@ -16,7 +15,7 @@
|
||||||
#if PY_MAJOR_VERSION < 3
|
#if PY_MAJOR_VERSION < 3
|
||||||
static bool IsStringType(PyObject* t) { return (void*)t == (void*)&PyString_Type; }
|
static bool IsStringType(PyObject* t) { return (void*)t == (void*)&PyString_Type; }
|
||||||
static bool IsUnicodeType(PyObject* t) { return (void*)t == (void*)&PyUnicode_Type; }
|
static bool IsUnicodeType(PyObject* t) { return (void*)t == (void*)&PyUnicode_Type; }
|
||||||
@@ -90,7 +99,7 @@ static bool Connect(PyObject* pConnectSt
|
@@ -90,7 +98,7 @@ static bool Connect(PyObject* pConnectSt
|
||||||
// indication that we can handle Unicode. We are going to use the same unicode ending
|
// indication that we can handle Unicode. We are going to use the same unicode ending
|
||||||
// as we do for binding parameters.
|
// as we do for binding parameters.
|
||||||
|
|
||||||
|
@ -25,7 +24,7 @@
|
||||||
if (!wchar)
|
if (!wchar)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -216,24 +225,24 @@ PyObject* Connection_New(PyObject* pConn
|
@@ -216,24 +224,24 @@ PyObject* Connection_New(PyObject* pConn
|
||||||
// single-byte text we don't actually know what the encoding is. For example, with SQL
|
// single-byte text we don't actually know what the encoding is. For example, with SQL
|
||||||
// Server the encoding is based on the database's collation. We ask the driver / DB to
|
// Server the encoding is based on the database's collation. We ask the driver / DB to
|
||||||
// convert to SQL_C_WCHAR and use the ODBC default of UTF-16LE.
|
// convert to SQL_C_WCHAR and use the ODBC default of UTF-16LE.
|
||||||
|
|
Loading…
Reference in a new issue