From 9c7c331bb985af321d99fbe64df54ad4aa1fc1d9 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sat, 24 Jul 2021 03:03:31 -0400
Subject: [PATCH] Fix LLSD serialization tests with python3

---
 indra/llcommon/tests/llsdserialize_test.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp
index c699ccd903e..3c42e519440 100644
--- a/indra/llcommon/tests/llsdserialize_test.cpp
+++ b/indra/llcommon/tests/llsdserialize_test.cpp
@@ -1795,7 +1795,7 @@ namespace tut
         set_test_name("verify NamedTempFile");
         python("platform",
                "import sys\n"
-               "print 'Running on', sys.platform\n");
+               "print('Running on %s' % sys.platform)\n");
     }
 
     // helper for test<3>
@@ -1825,14 +1825,14 @@ namespace tut
         const char pydata[] =
             "def verify(iterable):\n"
             "    it = iter(iterable)\n"
-            "    assert it.next() == 17\n"
-            "    assert abs(it.next() - 3.14) < 0.01\n"
-            "    assert it.next() == '''\\\n"
+            "    assert next(it) == 17\n"
+            "    assert abs(next(it) - 3.14) < 0.01\n"
+            "    assert next(it) == '''\\\n"
             "This string\n"
             "has several\n"
             "lines.'''\n"
             "    try:\n"
-            "        it.next()\n"
+            "        next(it)\n"
             "    except StopIteration:\n"
             "        pass\n"
             "    else:\n"
@@ -1852,7 +1852,7 @@ namespace tut
                import_llsd <<
                "def parse_each(iterable):\n"
                "    for item in iterable:\n"
-               "        yield llsd.parse(item)\n" <<
+               "        yield llsd.parse(item.encode(\"utf-8\"))\n" <<
                pydata <<
                // Don't forget raw-string syntax for Windows pathnames.
                "verify(parse_each(open(r'" << file.getName() << "')))\n");
@@ -1884,7 +1884,7 @@ namespace tut
                // N.B. Using 'print' implicitly adds newlines.
                "with open(r'" << file.getName() << "', 'w') as f:\n"
                "    for item in DATA:\n"
-               "        print >>f, llsd.format_notation(item)\n");
+               "        print(llsd.format_notation(item).decode(\"utf-8\"), file=f)\n");
 
         std::ifstream inf(file.getName().c_str());
         LLSD item;
-- 
GitLab