From 8660a7373eded9b9cbf624439999f405ac48eb83 Mon Sep 17 00:00:00 2001
From: Martyn Gigg <martyn.gigg@stfc.ac.uk>
Date: Mon, 23 Dec 2019 15:25:00 +0000
Subject: [PATCH] Use non-deprecated unicode conversion function

Refs #16578
---
 .../PythonInterface/mantid/kernel/src/Exports/UnitLabel.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/UnitLabel.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/UnitLabel.cpp
index 670d2418574..9330af21762 100644
--- a/Framework/PythonInterface/mantid/kernel/src/Exports/UnitLabel.cpp
+++ b/Framework/PythonInterface/mantid/kernel/src/Exports/UnitLabel.cpp
@@ -24,11 +24,13 @@ boost::shared_ptr<UnitLabel>
 createLabel(const object &ascii, const object &utf8, const object &latex) {
   using Utf8Char = UnitLabel::Utf8String::value_type;
   if (PyUnicode_Check(utf8.ptr())) {
-    auto length = PyUnicode_GetSize(utf8.ptr());
-    boost::scoped_array<Utf8Char> buffer(new Utf8Char[length]);
 #if PY_MAJOR_VERSION >= 3
+    auto length = PyUnicode_GetLength(utf8.ptr());
+    boost::scoped_array<Utf8Char> buffer(new Utf8Char[length]);
     PyUnicode_AsWideChar(utf8.ptr(), buffer.get(), length);
 #else
+    auto length = PyUnicode_GetSize(utf8.ptr());
+    boost::scoped_array<Utf8Char> buffer(new Utf8Char[length]);
     PyUnicode_AsWideChar(reinterpret_cast<PyUnicodeObject *>(utf8.ptr()),
                          buffer.get(), length);
 #endif
-- 
GitLab