Blame SOURCES/gtest-PR1839-Fix-Python3-support.patch

6c5532
From 149c0d24148da9a339d6c9d03e638a39c59731f6 Mon Sep 17 00:00:00 2001
6c5532
From: Peter Levine <plevine457@gmail.com>
6c5532
Date: Fri, 14 Sep 2018 19:40:51 -0400
6c5532
Subject: [PATCH] Fix Python3 support
6c5532
6c5532
---
6c5532
 googletest/test/googletest-env-var-test.py          |  4 ++--
6c5532
 googletest/test/googletest-filter-unittest.py       | 13 ++++++++-----
6c5532
 googletest/test/googletest-output-test.py           |  2 +-
6c5532
 googletest/test/googletest-throw-on-failure-test.py |  2 +-
6c5532
 googletest/test/googletest-uninitialized-test.py    |  4 ++--
6c5532
 googletest/test/gtest_xml_output_unittest.py        |  3 ++-
6c5532
 googletest/test/gtest_xml_test_utils.py             |  2 +-
6c5532
 7 files changed, 17 insertions(+), 13 deletions(-)
6c5532
6c5532
diff --git a/googletest/test/googletest-env-var-test.py b/googletest/test/googletest-env-var-test.py
6c5532
index e1efeee1e..2f0e406af 100755
6c5532
--- a/googletest/test/googletest-env-var-test.py
6c5532
+++ b/googletest/test/googletest-env-var-test.py
6c5532
@@ -45,8 +45,8 @@
6c5532
 
6c5532
 def AssertEq(expected, actual):
6c5532
   if expected != actual:
6c5532
-    print 'Expected: %s' % (expected,)
6c5532
-    print '  Actual: %s' % (actual,)
6c5532
+    print('Expected: %s' % (expected,))
6c5532
+    print('  Actual: %s' % (actual,))
6c5532
     raise AssertionError
6c5532
 
6c5532
 
6c5532
diff --git a/googletest/test/googletest-filter-unittest.py b/googletest/test/googletest-filter-unittest.py
6c5532
index dc0b5bd9a..6b32f2d21 100755
6c5532
--- a/googletest/test/googletest-filter-unittest.py
6c5532
+++ b/googletest/test/googletest-filter-unittest.py
6c5532
@@ -42,7 +42,10 @@
6c5532
 
6c5532
 import os
6c5532
 import re
6c5532
-import sets
6c5532
+try:
6c5532
+  from sets import Set as set  # For Python 2.3 compatibility
6c5532
+except ImportError:
6c5532
+  pass
6c5532
 import sys
6c5532
 import gtest_test_utils
6c5532
 
6c5532
@@ -57,7 +60,7 @@
6c5532
 if sys.executable:
6c5532
   os.environ['EMPTY_VAR'] = ''
6c5532
   child = gtest_test_utils.Subprocess(
6c5532
-      [sys.executable, '-c', 'import os; print \'EMPTY_VAR\' in os.environ'])
6c5532
+      [sys.executable, '-c', 'import os; print(\'EMPTY_VAR\' in os.environ)'])
6c5532
   CAN_PASS_EMPTY_ENV = eval(child.output)
6c5532
 
6c5532
 
6c5532
@@ -72,7 +75,7 @@
6c5532
   os.environ['UNSET_VAR'] = 'X'
6c5532
   del os.environ['UNSET_VAR']
6c5532
   child = gtest_test_utils.Subprocess(
6c5532
-      [sys.executable, '-c', 'import os; print \'UNSET_VAR\' not in os.environ'
6c5532
+      [sys.executable, '-c', 'import os; print(\'UNSET_VAR\' not in os.environ)'
6c5532
       ])
6c5532
   CAN_UNSET_ENV = eval(child.output)
6c5532
 
6c5532
@@ -245,14 +248,14 @@ def AssertPartitionIsValid(self, set_var, list_of_sets):
6c5532
     for slice_var in list_of_sets:
6c5532
       full_partition.extend(slice_var)
6c5532
     self.assertEqual(len(set_var), len(full_partition))
6c5532
-    self.assertEqual(sets.Set(set_var), sets.Set(full_partition))
6c5532
+    self.assertEqual(set(set_var), set(full_partition))
6c5532
 
6c5532
   def AdjustForParameterizedTests(self, tests_to_run):
6c5532
     """Adjust tests_to_run in case value parameterized tests are disabled."""
6c5532
 
6c5532
     global param_tests_present
6c5532
     if not param_tests_present:
6c5532
-      return list(sets.Set(tests_to_run) - sets.Set(PARAM_TESTS))
6c5532
+      return list(set(tests_to_run) - set(PARAM_TESTS))
6c5532
     else:
6c5532
       return tests_to_run
6c5532
 
6c5532
diff --git a/googletest/test/googletest-output-test.py b/googletest/test/googletest-output-test.py
6c5532
index 2d69e353a..1a9ee6e3b 100755
6c5532
--- a/googletest/test/googletest-output-test.py
6c5532
+++ b/googletest/test/googletest-output-test.py
6c5532
@@ -287,7 +287,7 @@ def testOutput(self):
6c5532
     # sequences when we read the golden file irrespective of an operating
6c5532
     # system used. Therefore, we need to strip those \r's from newlines
6c5532
     # unconditionally.
6c5532
-    golden = ToUnixLineEnding(golden_file.read())
6c5532
+    golden = ToUnixLineEnding(golden_file.read().decode())
6c5532
     golden_file.close()
6c5532
 
6c5532
     # We want the test to pass regardless of certain features being
6c5532
diff --git a/googletest/test/googletest-throw-on-failure-test.py b/googletest/test/googletest-throw-on-failure-test.py
6c5532
index 46cb9f6da..204e43e79 100755
6c5532
--- a/googletest/test/googletest-throw-on-failure-test.py
6c5532
+++ b/googletest/test/googletest-throw-on-failure-test.py
6c5532
@@ -68,7 +68,7 @@ def SetEnvVar(env_var, value):
6c5532
 def Run(command):
6c5532
   """Runs a command; returns True/False if its exit code is/isn't 0."""
6c5532
 
6c5532
-  print 'Running "%s". . .' % ' '.join(command)
6c5532
+  print('Running "%s". . .' % ' '.join(command))
6c5532
   p = gtest_test_utils.Subprocess(command)
6c5532
   return p.exited and p.exit_code == 0
6c5532
 
6c5532
diff --git a/googletest/test/googletest-uninitialized-test.py b/googletest/test/googletest-uninitialized-test.py
6c5532
index 5b7d1e74f..69595a0dd 100755
6c5532
--- a/googletest/test/googletest-uninitialized-test.py
6c5532
+++ b/googletest/test/googletest-uninitialized-test.py
6c5532
@@ -43,8 +43,8 @@ def Assert(condition):
6c5532
 
6c5532
 def AssertEq(expected, actual):
6c5532
   if expected != actual:
6c5532
-    print 'Expected: %s' % (expected,)
6c5532
-    print '  Actual: %s' % (actual,)
6c5532
+    print('Expected: %s' % (expected,))
6c5532
+    print('  Actual: %s' % (actual,))
6c5532
     raise AssertionError
6c5532
 
6c5532
 
6c5532
diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py
6c5532
index faedd4e6c..8669f19e5 100755
6c5532
--- a/googletest/test/gtest_xml_output_unittest.py
6c5532
+++ b/googletest/test/gtest_xml_output_unittest.py
6c5532
@@ -266,7 +266,8 @@ def testDefaultOutputFile(self):
6c5532
         'gtest_no_test_unittest')
6c5532
     try:
6c5532
       os.remove(output_file)
6c5532
-    except OSError, e:
6c5532
+    except OSError:
6c5532
+      e = sys.exc_info()[1]
6c5532
       if e.errno != errno.ENOENT:
6c5532
         raise
6c5532
 
6c5532
diff --git a/googletest/test/gtest_xml_test_utils.py b/googletest/test/gtest_xml_test_utils.py
6c5532
index 1e0358592..afcf55e0d 100755
6c5532
--- a/googletest/test/gtest_xml_test_utils.py
6c5532
+++ b/googletest/test/gtest_xml_test_utils.py
6c5532
@@ -94,7 +94,7 @@ def AssertEquivalentNodes(self, expected_node, actual_node):
6c5532
     self.assertEquals(
6c5532
         len(expected_children), len(actual_children),
6c5532
         'number of child elements differ in element ' + actual_node.tagName)
6c5532
-    for child_id, child in expected_children.iteritems():
6c5532
+    for child_id, child in expected_children.items():
6c5532
       self.assert_(child_id in actual_children,
6c5532
                    '<%s> is not in <%s> (in element %s)' %
6c5532
                    (child_id, actual_children, actual_node.tagName))