Skip to content

Commit e131eb8

Browse files
committed
change iLibCall - fix UnicodeDecodeError: ascii codec cannot decode byte 0xc3
1 parent 3d03952 commit e131eb8

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

itoolkit/lib/itoollib.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/* defining string methods */
2020
#if PY_MAJOR_VERSION < 3
2121
#define StringOBJ_FromASCII(str) PyString_FromString(str)
22+
#define StringOBJ_FromUTF8(str) PyString_FromString(str)
2223
#define PyBytes_AsString PyString_AsString
2324
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
2425
#define StringObj_Format PyString_Format
@@ -29,6 +30,7 @@
2930
#define PyInt_AsLong PyLong_AsLong
3031
#define PyInt_AS_LONG PyLong_AsLong
3132
#define StringOBJ_FromASCII(str) PyUnicode_DecodeASCII(str, strlen(str), NULL)
33+
#define StringOBJ_FromUTF8(str) PyUnicode_DecodeUTF8(str, strlen(str), NULL)
3234
#define PyString_Check PyUnicode_Check
3335
#define StringObj_Format PyUnicode_Format
3436
#define StringObj_Size PyUnicode_GET_SIZE
@@ -198,6 +200,9 @@ static PyObject *itoolib_xmlservice(PyObject *self, PyObject *args)
198200
}
199201

200202
data = _ibm_itool_call_xmlservice(ipc, ipc_len, ctl, ctl_len, xmlin, xmlin_len, pase_ccsid, ebcdic_ccsid);
203+
if (!pase_ccsid || pase_ccsid == 1208) {
204+
return StringOBJ_FromUTF8(data); /* ADC - 1.3 */
205+
}
201206
return StringOBJ_FromASCII(data);
202207
}
203208

setup-lite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='itoolkit-lite',
7-
version='1.2',
7+
version='1.3',
88
description='IBM i toolkit lite',
99
long_description='IBM i toolkit lite',
1010
# url='https://github.com/pypa/sampleproject',

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='itoolkit',
7-
version='1.2',
7+
version='1.3',
88
description='IBM i toolkit',
99
long_description='IBM i toolkit',
1010
# url='https://github.com/pypa/sampleproject',

0 commit comments

Comments
 (0)