1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
diff -aur a/python/modules/IcePy/Types.cpp b/python/modules/IcePy/Types.cpp
--- a/python/modules/IcePy/Types.cpp 2023-11-06 10:24:19.000000000 +0100
+++ b/python/modules/IcePy/Types.cpp 2025-01-16 03:39:44.227647112 +0100
@@ -455,14 +455,7 @@
assert(_sliceInfoType);
}
- IcePy::PyObjectHandle args = PyTuple_New(0);
- if(!args.get())
- {
- assert(PyErr_Occurred());
- throw AbortMarshaling();
- }
-
- PyObjectHandle sd = PyEval_CallObject(_slicedDataType, args.get());
+ PyObjectHandle sd = PyObject_CallObject(_slicedDataType, nullptr);
if(!sd.get())
{
assert(PyErr_Occurred());
@@ -488,7 +481,7 @@
int i = 0;
for(vector<Ice::SliceInfoPtr>::const_iterator p = slicedData->slices.begin(); p != slicedData->slices.end(); ++p)
{
- PyObjectHandle slice = PyEval_CallObject(_sliceInfoType, args.get());
+ PyObjectHandle slice = PyObject_CallObject(_sliceInfoType, nullptr);
if(!slice.get())
{
assert(PyErr_Occurred());
@@ -1669,18 +1662,17 @@
Py_ssize_t sz = 0;
if(p != Py_None)
{
- const void* buf = 0;
- if(PyObject_AsReadBuffer(p, &buf, &sz) == 0)
+ Py_buffer pybuf;
+ if(pi && PyObject_GetBuffer(p, &pybuf, PyBUF_SIMPLE | PyBUF_FORMAT) == 0)
{
- if(pi->kind == PrimitiveInfo::KindString)
- {
- PyErr_Format(PyExc_ValueError, STRCAST("expected sequence value"));
- throw AbortMarshaling();
- }
+ // Strings are handled as variable length types above.
+ assert(pi->kind != PrimitiveInfo::KindString);
+ sz = pybuf.len;
+ PyBuffer_Release(&pybuf);
}
else
{
- PyErr_Clear(); // PyObject_AsReadBuffer sets an exception on failure.
+ PyErr_Clear(); // PyObject_GetBuffer sets an exception on failure.
PyObjectHandle fs;
if(pi)
@@ -1906,7 +1898,7 @@
if(pi->kind != PrimitiveInfo::KindString)
{
//
- // With Python 3 and greater we marshal sequences of pritive types using the new
+ // With Python 3 and greater we marshal sequences of primitive types using the new
// buffer protocol when possible, for older versions we use the old buffer protocol.
//
#if PY_VERSION_HEX >= 0x03000000
@@ -2030,7 +2022,7 @@
}
else
{
- PyErr_Clear(); // PyObject_GetBuffer/PyObject_AsReadBuffer sets an exception on failure.
+ PyErr_Clear(); // PyObject_GetBuffer sets an exception on failure.
}
}
diff -aur a/python/modules/IcePy/Util.cpp b/python/modules/IcePy/Util.cpp
--- a/python/modules/IcePy/Util.cpp 2023-11-06 10:24:19.000000000 +0100
+++ b/python/modules/IcePy/Util.cpp 2025-01-16 03:39:44.227647112 +0100
@@ -729,12 +729,7 @@
IcePy::createExceptionInstance(PyObject* type)
{
assert(PyExceptionClass_Check(type));
- IcePy::PyObjectHandle args = PyTuple_New(0);
- if(!args.get())
- {
- return 0;
- }
- return PyEval_CallObject(type, args.get());
+ return PyObject_CallObject(type, nullptr);
}
static void
|