SF patch# 1766592 by Paul Colomiets.
Fix test_zipimport.
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 3f139fc..bc30a1a 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -209,7 +209,7 @@
         filename = _module_relative_path(package, filename)
         if hasattr(package, '__loader__'):
             if hasattr(package.__loader__, 'get_data'):
-                return package.__loader__.get_data(filename), filename
+                return package.__loader__.get_data(filename).decode('utf-8'), filename
     return open(filename, encoding="utf-8").read(), filename
 
 def _indent(s, indent=4):
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index 8daac4b..bae2172 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -153,18 +153,16 @@
 
     def testBadMagic(self):
         # make pyc magic word invalid, forcing loading from .py
-        m0 = ord(test_pyc[0])
-        m0 ^= 0x04  # flip an arbitrary bit
-        badmagic_pyc = chr(m0) + test_pyc[1:]
+        badmagic_pyc = bytes(test_pyc)
+        badmagic_pyc[0] ^= 0x04  # flip an arbitrary bit
         files = {TESTMOD + ".py": (NOW, test_src),
                  TESTMOD + pyc_ext: (NOW, badmagic_pyc)}
         self.doTest(".py", files, TESTMOD)
 
     def testBadMagic2(self):
         # make pyc magic word invalid, causing an ImportError
-        m0 = ord(test_pyc[0])
-        m0 ^= 0x04  # flip an arbitrary bit
-        badmagic_pyc = chr(m0) + test_pyc[1:]
+        badmagic_pyc = bytes(test_pyc)
+        badmagic_pyc[0] ^= 0x04  # flip an arbitrary bit
         files = {TESTMOD + pyc_ext: (NOW, badmagic_pyc)}
         try:
             self.doTest(".py", files, TESTMOD)
@@ -174,10 +172,9 @@
             self.fail("expected ImportError; import from bad pyc")
 
     def testBadMTime(self):
-        t3 = ord(test_pyc[7])
-        t3 ^= 0x02  # flip the second bit -- not the first as that one
-                    # isn't stored in the .py's mtime in the zip archive.
-        badtime_pyc = test_pyc[:7] + chr(t3) + test_pyc[8:]
+        badtime_pyc = bytes(test_pyc)
+        badtime_pyc[7] ^= 0x02  # flip the second bit -- not the first as that one
+                                # isn't stored in the .py's mtime in the zip archive.
         files = {TESTMOD + ".py": (NOW, test_src),
                  TESTMOD + pyc_ext: (NOW, badtime_pyc)}
         self.doTest(".py", files, TESTMOD)
@@ -232,7 +229,7 @@
         z.compression = self.compression
         try:
             name = "testdata.dat"
-            data = "".join([chr(x) for x in range(256)]) * 500
+            data = bytes(x for x in range(256))
             z.writestr(name, data)
             z.close()
             zi = zipimport.zipimporter(TEMP_ZIP)
@@ -246,7 +243,7 @@
         src = """if 1:  # indent hack
         def get_file():
             return __file__
-        if __loader__.get_data("some.data") != "some data":
+        if __loader__.get_data("some.data") != b"some data":
             raise AssertionError, "bad data"\n"""
         pyc = make_pyc(compile(src, "<???>", "exec"), NOW)
         files = {TESTMOD + pyc_ext: (NOW, pyc),