diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/ComponentInfoPythonIterator.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/ComponentInfoPythonIterator.cpp index 83fdd03e79770f4c51bd334a97f6ef41c6a5437a..8481f68b5bd72527a8560ba74f8773d09390d1d7 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/ComponentInfoPythonIterator.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/ComponentInfoPythonIterator.cpp @@ -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 diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/DetectorInfoPythonIterator.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/DetectorInfoPythonIterator.cpp index 2f104addd520e52c1b02cd755003388571e59bf8..68816097784342fecfe4ce00fa99cde4ca8cdbc8 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/DetectorInfoPythonIterator.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/DetectorInfoPythonIterator.cpp @@ -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