Skip to content

Commit

Permalink
Additional fixes & simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone committed Oct 17, 2024
1 parent e54e899 commit c92eb05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
21 changes: 6 additions & 15 deletions python/modules/IcePy/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,7 @@ IcePy::StreamUtil::setSlicedDataMember(PyObject* obj, const Ice::SlicedDataPtr&
assert(_sliceInfoType);
}

IcePy::PyObjectHandle args{PyTuple_New(0)};
if (!args.get())
{
assert(PyErr_Occurred());
throw AbortMarshaling();
}

PyObjectHandle sd{PyObject_CallObject(_slicedDataType, args.get())};
PyObjectHandle sd{PyObject_CallObject(_slicedDataType, nullptr)};
if (!sd.get())
{
assert(PyErr_Occurred());
Expand All @@ -329,7 +322,7 @@ IcePy::StreamUtil::setSlicedDataMember(PyObject* obj, const Ice::SlicedDataPtr&
int i = 0;
for (vector<Ice::SliceInfoPtr>::const_iterator p = slicedData->slices.begin(); p != slicedData->slices.end(); ++p)
{
PyObjectHandle slice{PyObject_CallObject(_sliceInfoType, args.get())};
PyObjectHandle slice{PyObject_CallObject(_sliceInfoType, nullptr)};
if (!slice.get())
{
assert(PyErr_Occurred());
Expand Down Expand Up @@ -1477,14 +1470,12 @@ IcePy::SequenceInfo::marshal(
if (p != Py_None)
{
Py_buffer pybuf;
if (PyObject_GetBuffer(p, &pybuf, PyBUF_SIMPLE | PyBUF_FORMAT) == 0)
if (pi && PyObject_GetBuffer(p, &pybuf, PyBUF_SIMPLE | PyBUF_FORMAT) == 0)
{
if (pi->kind == PrimitiveInfo::KindString)
{
PyErr_Format(PyExc_ValueError, "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
{
Expand Down
7 changes: 1 addition & 6 deletions python/modules/IcePy/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,7 @@ PyObject*
IcePy::createExceptionInstance(PyObject* type)
{
assert(PyExceptionClass_Check(type));
IcePy::PyObjectHandle args{PyTuple_New(0)};
if (!args.get())
{
return nullptr;
}
return PyObject_CallObject(type, args.get());
return PyObject_CallObject(type, nullptr);
}

namespace
Expand Down

0 comments on commit c92eb05

Please sign in to comment.