mirror of
https://github.com/boostorg/python.git
synced 2026-01-22 17:32:55 +00:00
Merged 2009 GSoC work from sandbox-branches/bhy/py3k branch back into trunk.
[SVN r56305]
This commit is contained in:
22
src/list.cpp
22
src/list.cpp
@@ -48,7 +48,11 @@ void list_base::extend(object_cref sequence)
|
||||
long list_base::index(object_cref value) const
|
||||
{
|
||||
object result_obj(this->attr("index")(value));
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
ssize_t result = PyLong_AsSsize_t(result_obj.ptr());
|
||||
#else
|
||||
long result = PyInt_AsLong(result_obj.ptr());
|
||||
#endif
|
||||
if (result == -1)
|
||||
throw_error_already_set();
|
||||
return result;
|
||||
@@ -69,7 +73,11 @@ void list_base::insert(ssize_t index, object_cref item)
|
||||
|
||||
void list_base::insert(object const& index, object_cref x)
|
||||
{
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
ssize_t index_ = PyLong_AsSsize_t(index.ptr());
|
||||
#else
|
||||
long index_ = PyInt_AsLong(index.ptr());
|
||||
#endif
|
||||
if (index_ == -1 && PyErr_Occurred())
|
||||
throw_error_already_set();
|
||||
this->insert(index_, x);
|
||||
@@ -121,17 +129,29 @@ void list_base::sort()
|
||||
}
|
||||
}
|
||||
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
void list_base::sort(args_proxy const &args,
|
||||
kwds_proxy const &kwds)
|
||||
{
|
||||
this->attr("sort")(args, kwds);
|
||||
}
|
||||
#else
|
||||
void list_base::sort(object_cref cmpfunc)
|
||||
{
|
||||
this->attr("sort")(cmpfunc);
|
||||
}
|
||||
#endif
|
||||
|
||||
// For some reason, moving this to the end of the TU suppresses an ICE
|
||||
// with vc6.
|
||||
long list_base::count(object_cref value) const
|
||||
Py_ssize_t list_base::count(object_cref value) const
|
||||
{
|
||||
object result_obj(this->attr("count")(value));
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
Py_ssize_t result = PyLong_AsSsize_t(result_obj.ptr());
|
||||
#else
|
||||
long result = PyInt_AsLong(result_obj.ptr());
|
||||
#endif
|
||||
if (result == -1)
|
||||
throw_error_already_set();
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user