Skip to content

Commit 89e5f29

Browse files
Support for python3.12 (#913)
* Support for python3.12 Signed-off-by: Balram Choudhary <bchoudhary@rocketsoftware.com>
1 parent 443cd61 commit 89e5f29

File tree

5 files changed

+29
-23
lines changed

5 files changed

+29
-23
lines changed

.github/workflows/bld_wheels_and_upload.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ jobs:
1919
matrix:
2020
os: [windows-latest]
2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4.1.1
2323
- name: Build wheels
24-
uses: pypa/cibuildwheel@v2.12.2
24+
uses: pypa/cibuildwheel@v2.16.5
2525
env:
2626
CIBW_BUILD: "*-win_amd64"
2727
CIBW_SKIP: "cp36-* pp*"
28-
- uses: actions/upload-artifact@v3
28+
- uses: actions/upload-artifact@v4.3.1
2929
with:
3030
path: ./wheelhouse/*.whl
3131

@@ -36,9 +36,9 @@ jobs:
3636
matrix:
3737
os: [windows-latest]
3838
steps:
39-
- uses: actions/checkout@v3
39+
- uses: actions/checkout@v4.1.1
4040
- name: Build wheels
41-
uses: pypa/cibuildwheel@v2.12.2
41+
uses: pypa/cibuildwheel@v2.16.5
4242
env:
4343
CIBW_BUILD: "*-win32"
4444
CIBW_SKIP: "cp36-* pp*"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ https://github.com/ibmdb/python-ibmdb/wiki/APIs
2020

2121
<a name="prereq"></a>
2222
## Pre-requisites
23-
Install Python 3.7 <= 3.11. The minimum python version supported by driver is python 3.7 and the latest version supported is python 3.11.
23+
Install Python 3.7 <= 3.12. The minimum python version supported by driver is python 3.7 and the latest version supported is python 3.12.
2424

2525
### To install ibm_db on z/OS system
2626

ibm_db.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -1438,19 +1438,19 @@ static PyObject *_python_ibm_db_connect_helper( PyObject *self, PyObject *args,
14381438
#ifdef __MVS__
14391439
rc = SQLConnectW((SQLHDBC)conn_res->hdbc,
14401440
database,
1441-
PyUnicode_GetSize(databaseObj)*2,
1441+
PyUnicode_GetLength(databaseObj)*2,
14421442
uid,
1443-
PyUnicode_GetSize(uidObj)*2,
1443+
PyUnicode_GetLength(uidObj)*2,
14441444
password,
1445-
PyUnicode_GetSize(passwordObj)*2);
1445+
PyUnicode_GetLength(passwordObj)*2);
14461446
#else
14471447
rc = SQLConnectW((SQLHDBC)conn_res->hdbc,
14481448
database,
1449-
PyUnicode_GetSize(databaseObj),
1449+
PyUnicode_GetLength(databaseObj),
14501450
uid,
1451-
PyUnicode_GetSize(uidObj),
1451+
PyUnicode_GetLength(uidObj),
14521452
password,
1453-
PyUnicode_GetSize(passwordObj));
1453+
PyUnicode_GetLength(passwordObj));
14541454
#endif
14551455
Py_END_ALLOW_THREADS;
14561456
}
@@ -1579,7 +1579,7 @@ static PyObject* getSQLWCharAsPyUnicodeObject(SQLWCHAR* sqlwcharData, int sqlwch
15791579

15801580
if (maxuniValue <= 65536) {
15811581
/* this is UCS2 python.. nothing to do really */
1582-
return PyUnicode_FromUnicode((Py_UNICODE *)sqlwcharData, sqlwcharBytesLen / sizeof(SQLWCHAR));
1582+
return PyUnicode_FromWideChar((Py_UNICODE *)sqlwcharData, sqlwcharBytesLen / sizeof(SQLWCHAR));
15831583
}
15841584

15851585
if (is_bigendian()) {
@@ -1619,15 +1619,15 @@ static SQLWCHAR* getUnicodeDataAsSQLWCHAR(PyObject *pyobj, int *isNewBuffer)
16191619
long maxuniValue;
16201620
PyObject *pyUTFobj;
16211621
SQLWCHAR* pNewBuffer = NULL;
1622-
int nCharLen = PyUnicode_GET_SIZE(pyobj);
1622+
int nCharLen = PyUnicode_GET_LENGTH(pyobj);
16231623

16241624
sysmodule = PyImport_ImportModule("sys");
16251625
maxuni = PyObject_GetAttrString(sysmodule, "maxunicode");
16261626
maxuniValue = PyInt_AsLong(maxuni);
16271627

16281628
if (maxuniValue <= 65536) {
16291629
*isNewBuffer = 0;
1630-
return (SQLWCHAR*)PyUnicode_AS_UNICODE(pyobj);
1630+
return (SQLWCHAR*)PyUnicode_AsWideCharString(pyobj,maxuniValue);
16311631
}
16321632

16331633
*isNewBuffer = 1;
@@ -5373,7 +5373,7 @@ static PyObject *_python_ibm_db_prepare_helper(conn_handle *conn_res, PyObject *
53735373
if (PyString_Check(py_stmt) || PyUnicode_Check(py_stmt)) {
53745374
py_stmt = PyUnicode_FromObject(py_stmt);
53755375
if (py_stmt != NULL && py_stmt != Py_None) {
5376-
stmt_size = PyUnicode_GetSize(py_stmt);
5376+
stmt_size = PyUnicode_GetLength(py_stmt);
53775377
} else {
53785378
PyErr_SetString(PyExc_Exception, "Error occure during processing of statement");
53795379
return NULL;
@@ -5893,7 +5893,7 @@ static int _python_ibm_db_bind_data( stmt_handle *stmt_res, param_node *curr, Py
58935893
tmp_uvalue = NULL;
58945894
}
58955895
tmp_uvalue = getUnicodeDataAsSQLWCHAR(item, &isNewBuffer);
5896-
curr->ivalue = PyUnicode_GetSize(item);
5896+
curr->ivalue = PyUnicode_GetLength(item);
58975897
curr->ivalue = curr->ivalue * sizeof(SQLWCHAR);
58985898
}
58995899
param_length = curr->ivalue;
@@ -6060,7 +6060,7 @@ static int _python_ibm_db_bind_data( stmt_handle *stmt_res, param_node *curr, Py
60606060
curr->uvalue = NULL;
60616061
}
60626062
curr->uvalue = getUnicodeDataAsSQLWCHAR(bind_data, &isNewBuffer);
6063-
curr->ivalue = PyUnicode_GetSize(bind_data);
6063+
curr->ivalue = PyUnicode_GetLength(bind_data);
60646064
curr->ivalue = curr->ivalue * sizeof(SQLWCHAR);
60656065
}
60666066
param_length = curr->ivalue;

ibm_db.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#define StringOBJ_FromStr(str) PyUnicode_DecodeLocale(str, NULL)
4848
#define PyString_Check PyUnicode_Check
4949
#define StringObj_Format PyUnicode_Format
50-
#define StringObj_Size PyUnicode_GET_SIZE
50+
#define StringObj_Size PyUnicode_GET_LENGTH
5151
#define MOD_RETURN_ERROR NULL
5252
#define MOD_RETURN_VAL(mod) mod
5353
#define INIT_ibm_db PyInit_ibm_db

setup.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
import urllib2 as request
1919
from cStringIO import StringIO as BytesIO
2020

21-
from distutils import ccompiler
22-
from distutils import sysconfig as distutils_sysconfig
23-
from distutils.sysconfig import get_python_lib
21+
if sys.version_info.major == 3 and sys.version_info.minor >= 12:
22+
from setuptools._distutils import ccompiler
23+
from setuptools._distutils import sysconfig as distutils_sysconfig
24+
from setuptools._distutils.sysconfig import get_python_lib
25+
else:
26+
from distutils import ccompiler
27+
from distutils import sysconfig as distutils_sysconfig
28+
from distutils.sysconfig import get_python_lib
2429
from setuptools import setup, find_packages, Extension
2530
from setuptools.command.build_ext import build_ext
2631
from setuptools.command.install import install
@@ -62,7 +67,7 @@ def _printAndExit(msg):
6267

6368
def _errormessage(option):
6469
if(option == "downloadFailedWin"):
65-
message = "\nPlease download the clidriver manually from the above link and unzip the contents into a particular location.\nSet the location of the directory to the system enviroment variable \"IBM_DB_HOME\"\nExample set IBM_DB_HOME=C:\downloads\db2driver\clidriver\nOnce the above settings are done please try installing ibm_db again."
70+
message = "\nPlease download the clidriver manually from the above link and unzip the contents into a particular location.\nSet the location of the directory to the system enviroment variable \"IBM_DB_HOME\"\nExample set IBM_DB_HOME=C:/downloads/db2driver/clidriver\nOnce the above settings are done please try installing ibm_db again."
6671
if(option == "downloadFailed"):
6772
message = "\nPlease download the clidriver manually from the above link and untar the contents into a particular directory.\nSet the location of the directory to the system enviroment variable \"IBM_DB_HOME\"\nExample export IBM_DB_HOME=/home/db2driver/clidriver\nOnce the above settings are done try installing ibm_db again."
6873
if(option == "includeFolderMissing"):
@@ -525,6 +530,7 @@ def print_exception( e, url):
525530
'Programming Language :: Python :: 3.9',
526531
'Programming Language :: Python :: 3.10',
527532
'Programming Language :: Python :: 3.11',
533+
'Programming Language :: Python :: 3.12',
528534
'Topic :: Database :: Front-Ends'],
529535

530536
long_description = 'Python DBI driver for IBM Db2 for LUW, IBM Informix, IBM Db2 for iSeries(AS400) and IBM Db2 for z/OS servers',

0 commit comments

Comments
 (0)