code: def _fix_spoof_python2(runner, encoding):
      """
      Installs a "SpoofOut" into the given DebugRunner so it properly deals with unicode output. This
      should patch only doctests for text files because they don't have a way to declare their
      encoding. Doctests in docstrings from Python modules don't have the same problem given that
      Python already decoded the strings.
  
      This fixes the problem related in issue #2434.
      """
      from _pytest.compat import _PY2
  
      if not _PY2:
          return
  
      from doctest import _SpoofOut
  
      class UnicodeSpoof(_SpoofOut):
          def getvalue(self):
              result = _SpoofOut.getvalue(self)
              if encoding and isinstance(result, bytes):
                  result = result.decode(encoding)
              return result
  
      runner._fakeout = UnicodeSpoof()
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import inspect
  import platform
  import sys
  import traceback
  import warnings
  from contextlib import contextmanager
  import pytest
  from _pytest._code.code import ExceptionInfo
  from _pytest._code.code import ReprFileLocation
  from _pytest._code.code import TerminalRepr
  from _pytest.compat import safe_getattr
  from _pytest.fixtures import FixtureRequest
  from _pytest.outcomes import Skipped
  from _pytest.warning_types import PytestWarning
label_desc: Use image node_id 18 for calling a global function with example usage: _fix_spoof_python2(runner, encoding) and returns: result