From cc837c578924b830a06b3544de6d4145ba1976cf Mon Sep 17 00:00:00 2001
From: Owen Arnold <owen.arnold@stfc.ac.uk>
Date: Mon, 21 Jan 2019 12:34:07 +0000
Subject: [PATCH] refs #24322. Return value policy for py2 only

---
 .../src/Exports/ComponentInfoPythonIterator.cpp    | 12 +++++-------
 .../src/Exports/DetectorInfoPythonIterator.cpp     | 14 ++++++--------
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/ComponentInfoPythonIterator.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/ComponentInfoPythonIterator.cpp
index 83fdd03e797..8481f68b5bd 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 2f104addd52..68816097784 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
-- 
GitLab