Skip to content
Snippets Groups Projects
Commit cc837c57 authored by Owen Arnold's avatar Owen Arnold
Browse files

refs #24322. Return value policy for py2 only

parent f3b9bdb6
No related merge requests found
......@@ -20,15 +20,13 @@ void export_ComponentInfoPythonIterator() {
// Export to Python
class_<ComponentInfoPythonIterator>("ComponentInfoPythonIterator", no_init)
.def("__iter__", objects::identity_function())
.def(
#if PY_VERSION_HEX >= 0x03000000
"__next__"
#ifdef IS_PY3K
.def("__next__", &ComponentInfoPythonIterator::next)
#else
"next"
.def("next", &ComponentInfoPythonIterator::next,
return_value_policy<copy_const_reference>())
#endif
,
&ComponentInfoPythonIterator::next,
return_value_policy<copy_const_reference>());
;
/*
Return value policy for next is to copy the const reference. Copy by value is
essential for python 2.0 compatibility because items (DetectorInfoItem) will
......
......@@ -5,7 +5,7 @@
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidPythonInterface/api/DetectorInfoPythonIterator.h"
#include "MantidPythonInterface/core/VersionCompat.h"
#include <boost/python/class.hpp>
#include <boost/python/copy_const_reference.hpp>
#include <boost/python/iterator.hpp>
......@@ -20,15 +20,13 @@ void export_DetectorInfoPythonIterator() {
// Export to Python
class_<DetectorInfoPythonIterator>("DetectorInfoPythonIterator", no_init)
.def("__iter__", objects::identity_function())
.def(
#if PY_VERSION_HEX >= 0x03000000
"__next__"
#ifdef IS_PY3K
.def("__next__", &DetectorInfoPythonIterator::next)
#else
"next"
.def("next", &DetectorInfoPythonIterator::next,
return_value_policy<copy_const_reference>())
#endif
,
&DetectorInfoPythonIterator::next,
return_value_policy<copy_const_reference>());
;
/*
Return value policy for next is to copy the const reference. Copy by value is
essential for python 2.0 compatibility because items (DetectorInfoItem) will
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment