From 0b02fd4e995381dc3564874898eb637f70bdf089 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 22 Aug 2002 19:08:16 +0000 Subject: [PATCH] Use make_tuple() [SVN r15062] --- test/pickle1.cpp | 5 +---- test/pickle2.cpp | 9 ++------- test/pickle3.cpp | 16 +++++----------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/test/pickle1.cpp b/test/pickle1.cpp index eab90299..647ef249 100644 --- a/test/pickle1.cpp +++ b/test/pickle1.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -39,9 +38,7 @@ namespace { getinitargs(const world& w) { using namespace boost::python; - list result; - result.append(object(w.get_country())); - return tuple(result); + return make_tuple(w.get_country()); } }; diff --git a/test/pickle2.cpp b/test/pickle2.cpp index 6fe2962d..cf099738 100644 --- a/test/pickle2.cpp +++ b/test/pickle2.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -54,9 +53,7 @@ namespace { // Avoid cluttering the global namespace. getinitargs(const world& w) { using namespace boost::python; - list result; - result.append(object(w.get_country())); - return tuple(result); + return make_tuple(w.get_country()); } static @@ -64,9 +61,7 @@ namespace { // Avoid cluttering the global namespace. getstate(const world& w) { using namespace boost::python; - list result; - result.append(object(w.get_secret_number())); - return tuple(result); + return make_tuple(w.get_secret_number()); } static diff --git a/test/pickle3.cpp b/test/pickle3.cpp index f4f8c20e..105bac51 100644 --- a/test/pickle3.cpp +++ b/test/pickle3.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -50,9 +49,7 @@ namespace { // Avoid cluttering the global namespace. getinitargs(const world& w) { using namespace boost::python; - list result; - result.append(object(w.get_country())); - return tuple(result); + return make_tuple(w.get_country()); } static @@ -61,12 +58,8 @@ namespace { // Avoid cluttering the global namespace. { using namespace boost::python; world const& w = extract(w_obj)(); - list result; - // store the object's __dict__ - result.append(w_obj.attr("__dict__")); - // store the internal state of the C++ object - result.append(object(w.get_secret_number())); - return tuple(result); + + return make_tuple(w_obj.attr("__dict__"), w.get_secret_number()); } static @@ -76,7 +69,8 @@ namespace { // Avoid cluttering the global namespace. using namespace boost::python; world& w = extract(w_obj)(); extract state_proxy(state); - if (!state_proxy.check() || len(state_proxy()) != 2) { + if (!state_proxy.check() || len(state_proxy()) != 2) + { PyErr_SetString(PyExc_ValueError, "Unexpected argument in call to __setstate__."); throw_error_already_set();