Py: [skip ci] replace PyList_Append with Py::List::append
This commit is contained in:
@@ -544,15 +544,8 @@ void InterpreterSingleton::addType(PyTypeObject* Type,PyObject* Module, const ch
|
||||
void InterpreterSingleton::addPythonPath(const char* Path)
|
||||
{
|
||||
PyGILStateLocker locker;
|
||||
PyObject *list = PySys_GetObject("path");
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyObject *path = PyUnicode_FromString(Path);
|
||||
#else
|
||||
PyObject *path = PyString_FromString(Path);
|
||||
#endif
|
||||
PyList_Append(list, path);
|
||||
Py_DECREF(path);
|
||||
PySys_SetObject("path", list);
|
||||
Py::List list(PySys_GetObject("path"));
|
||||
list.append(Py::String(Path));
|
||||
}
|
||||
|
||||
const char* InterpreterSingleton::init(int argc,char *argv[])
|
||||
|
||||
@@ -469,7 +469,7 @@ PyObject* ExternalGeometryFacadePy::getExtensions(PyObject *args)
|
||||
try {
|
||||
const std::vector<std::weak_ptr<const Part::GeometryExtension>> ext = this->getExternalGeometryFacadePtr()->getExtensions();
|
||||
|
||||
PyObject* list = PyList_New(0);
|
||||
Py::List list;
|
||||
|
||||
for (std::size_t i=0; i<ext.size(); ++i) {
|
||||
|
||||
@@ -478,9 +478,7 @@ PyObject* ExternalGeometryFacadePy::getExtensions(PyObject *args)
|
||||
if(p) {
|
||||
// we create a python copy and add it to the list
|
||||
try {
|
||||
PyObject* cpy = p->copyPyObject();
|
||||
PyList_Append( list, cpy);
|
||||
Py_DECREF(cpy);
|
||||
list.append(Py::asObject(p->copyPyObject()));
|
||||
}
|
||||
catch(Base::NotImplementedError) {
|
||||
// silently ignoring extensions not having a Python object
|
||||
@@ -488,7 +486,7 @@ PyObject* ExternalGeometryFacadePy::getExtensions(PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
return Py::new_reference_to(list);
|
||||
}
|
||||
catch(const Base::ValueError& e) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, e.what());
|
||||
|
||||
@@ -447,7 +447,7 @@ PyObject* GeometryFacadePy::getExtensions(PyObject *args)
|
||||
try {
|
||||
const std::vector<std::weak_ptr<const Part::GeometryExtension>> ext = this->getGeometryFacadePtr()->getExtensions();
|
||||
|
||||
PyObject* list = PyList_New(0);
|
||||
Py::List list;
|
||||
|
||||
for (std::size_t i=0; i<ext.size(); ++i) {
|
||||
|
||||
@@ -456,9 +456,7 @@ PyObject* GeometryFacadePy::getExtensions(PyObject *args)
|
||||
if(p) {
|
||||
// we create a python copy and add it to the list
|
||||
try {
|
||||
PyObject* cpy = p->copyPyObject();
|
||||
PyList_Append( list, cpy);
|
||||
Py_DECREF(cpy);
|
||||
list.append(Py::asObject(p->copyPyObject()));
|
||||
}
|
||||
catch(Base::NotImplementedError) {
|
||||
// silently ignoring extensions not having a Python object
|
||||
@@ -466,7 +464,7 @@ PyObject* GeometryFacadePy::getExtensions(PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
return Py::new_reference_to(list);
|
||||
}
|
||||
catch(const Base::ValueError& e) {
|
||||
PyErr_SetString(Part::PartExceptionOCCError, e.what());
|
||||
|
||||
Reference in New Issue
Block a user