mirror of
https://github.com/boostorg/python.git
synced 2026-01-21 05:02:17 +00:00
Added type checking when converting some Python types from python as return values.
[SVN r14478]
This commit is contained in:
44
src/list.cpp
44
src/list.cpp
@@ -24,8 +24,15 @@ BOOST_PYTHON_DECL list::list(object_cref sequence)
|
||||
|
||||
BOOST_PYTHON_DECL void list::append(object_cref x)
|
||||
{
|
||||
if (PyList_Append(this->ptr(), x.ptr()) == -1)
|
||||
throw_error_already_set();
|
||||
if (PyList_CheckExact(this->ptr()))
|
||||
{
|
||||
if (PyList_Append(this->ptr(), x.ptr()) == -1)
|
||||
throw_error_already_set();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->attr("append")(x);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL long list::count(object_cref value) const
|
||||
@@ -53,8 +60,15 @@ BOOST_PYTHON_DECL long list::index(object_cref value) const
|
||||
|
||||
BOOST_PYTHON_DECL void list::insert(int index, object_cref item)
|
||||
{
|
||||
if (PyList_Insert(this->ptr(), index, item.ptr()) == -1)
|
||||
throw_error_already_set();
|
||||
if (PyList_CheckExact(this->ptr()))
|
||||
{
|
||||
if (PyList_Insert(this->ptr(), index, item.ptr()) == -1)
|
||||
throw_error_already_set();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->attr("insert")(index, item);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL void list::insert(object const& index, object_cref x)
|
||||
@@ -87,14 +101,28 @@ BOOST_PYTHON_DECL void list::remove(object_cref value)
|
||||
|
||||
BOOST_PYTHON_DECL void list::reverse()
|
||||
{
|
||||
if (PyList_Reverse(this->ptr()) == -1)
|
||||
throw_error_already_set();
|
||||
if (PyList_CheckExact(this->ptr()))
|
||||
{
|
||||
if (PyList_Reverse(this->ptr()) == -1)
|
||||
throw_error_already_set();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->attr("reverse")();
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL void list::sort()
|
||||
{
|
||||
if (PyList_Sort(this->ptr()) == -1)
|
||||
throw_error_already_set();
|
||||
if (PyList_CheckExact(this->ptr()))
|
||||
{
|
||||
if (PyList_Sort(this->ptr()) == -1)
|
||||
throw_error_already_set();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->attr("sort")();
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL void list::sort(object_cref cmpfunc)
|
||||
|
||||
Reference in New Issue
Block a user