Change the way the encoding parameter is handled.
This fixes test_doctest with strict bytes/str.
diff --git a/Lib/doctest.py b/Lib/doctest.py
index ec51657..3fd4ecd 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -203,14 +203,14 @@
     else:
         raise TypeError("Expected a module, string, or None")
 
-def _load_testfile(filename, package, module_relative):
+def _load_testfile(filename, package, module_relative, encoding):
     if module_relative:
         package = _normalize_module(package, 3)
         filename = _module_relative_path(package, filename)
         if hasattr(package, '__loader__'):
             if hasattr(package.__loader__, 'get_data'):
                 return package.__loader__.get_data(filename).decode('utf-8'), filename
-    return open(filename, encoding="utf-8").read(), filename
+    return open(filename, encoding=encoding).read(), filename
 
 def _indent(s, indent=4):
     """
@@ -1890,7 +1890,8 @@
                          "relative paths.")
 
     # Relativize the path
-    text, filename = _load_testfile(filename, package, module_relative)
+    text, filename = _load_testfile(filename, package, module_relative,
+                                    encoding or "utf-8")
 
     # If no name was given, then use the file's name.
     if name is None:
@@ -1909,9 +1910,6 @@
     else:
         runner = DocTestRunner(verbose=verbose, optionflags=optionflags)
 
-    if encoding is not None:
-        text = text.decode(encoding)
-
     # Read the file, convert it to a test, and run it.
     test = parser.get_doctest(text, globs, name, filename, 0)
     runner.run(test)
@@ -2292,7 +2290,8 @@
                          "relative paths.")
 
     # Relativize the path.
-    doc, path = _load_testfile(path, package, module_relative)
+    doc, path = _load_testfile(path, package, module_relative,
+                               encoding or "utf-8")
 
     if "__file__" not in globs:
         globs["__file__"] = path
@@ -2300,10 +2299,6 @@
     # Find the file and read it.
     name = os.path.basename(path)
 
-    # If an encoding is specified, use it to convert the file to unicode
-    if encoding is not None:
-        doc = doc.decode(encoding)
-
     # Convert it to a test, and wrap it in a DocFileCase.
     test = parser.get_doctest(doc, globs, name, path, 0)
     return DocFileCase(test, **options)