From 5b9d28501da20bf3d95df2e8e28e468fb4185bcf Mon Sep 17 00:00:00 2001 From: Owen Arnold <owen.arnold@stfc.ac.uk> Date: Mon, 28 Jan 2019 15:42:54 +0000 Subject: [PATCH] refs #24597. Check against v2 python. --- .../core/inc/MantidPythonInterface/core/VersionCompat.h | 1 + .../geometry/src/Exports/ComponentInfoPythonIterator.cpp | 6 +++--- .../geometry/src/Exports/DetectorInfoPythonIterator.cpp | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Framework/PythonInterface/core/inc/MantidPythonInterface/core/VersionCompat.h b/Framework/PythonInterface/core/inc/MantidPythonInterface/core/VersionCompat.h index 3ebff5f6707..2ca2f7ffc88 100644 --- a/Framework/PythonInterface/core/inc/MantidPythonInterface/core/VersionCompat.h +++ b/Framework/PythonInterface/core/inc/MantidPythonInterface/core/VersionCompat.h @@ -20,6 +20,7 @@ #define FROM_CSTRING PyUnicode_FromString #define CODE_OBJECT(x) x #else +#define IS_PY2K #define INT_CHECK PyInt_Check #define TO_LONG PyInt_AsLong #define STR_CHECK PyString_Check diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/ComponentInfoPythonIterator.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/ComponentInfoPythonIterator.cpp index a07add6f07d..f8cb7fbf5e4 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/ComponentInfoPythonIterator.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/ComponentInfoPythonIterator.cpp @@ -19,10 +19,10 @@ void export_ComponentInfoPythonIterator() { // Export to Python class_<ComponentInfoPythonIterator>("ComponentInfoPythonIterator", no_init) .def("__iter__", objects::identity_function()) -#ifdef IS_PY3K - .def("__next__", &ComponentInfoPythonIterator::next) -#else +#ifdef IS_PY2K .def("next", &ComponentInfoPythonIterator::next) +#else + .def("__next__", &ComponentInfoPythonIterator::next) #endif ; } diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/DetectorInfoPythonIterator.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/DetectorInfoPythonIterator.cpp index 0c7db21d735..2cf6fc8bc1c 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/DetectorInfoPythonIterator.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/DetectorInfoPythonIterator.cpp @@ -19,10 +19,10 @@ void export_DetectorInfoPythonIterator() { // Export to Python class_<DetectorInfoPythonIterator>("DetectorInfoPythonIterator", no_init) .def("__iter__", objects::identity_function()) -#ifdef IS_PY3K - .def("__next__", &DetectorInfoPythonIterator::next) -#else +#ifdef IS_PY2K .def("next", &DetectorInfoPythonIterator::next) +#else + .def("__next__", &DetectorInfoPythonIterator::next) #endif ; } -- GitLab