code: def _enter_pdb(node, excinfo, rep):
      # XXX we re-use the TerminalReporter's terminalwriter
      # because this seems to avoid some encoding related troubles
      # for not completely clear reasons.
      tw = node.config.pluginmanager.getplugin("terminalreporter")._tw
      tw.line()
  
      showcapture = node.config.option.showcapture
  
      for sectionname, content in (
          ("stdout", rep.capstdout),
          ("stderr", rep.capstderr),
          ("log", rep.caplog),
      ):
          if showcapture in (sectionname, "all") and content:
              tw.sep(">", "captured " + sectionname)
              if content[-1:] == "\n":
                  content = content[:-1]
              tw.line(content)
  
      tw.sep(">", "traceback")
      rep.toterminal(tw)
      tw.sep(">", "entering PDB")
      tb = _postmortem_traceback(excinfo)
      rep._pdbshown = True
      post_mortem(tb)
      return rep
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import argparse
  import pdb
  import sys
  from doctest import UnexpectedException
  from _pytest import outcomes
  from _pytest.config import hookimpl
  from _pytest.config.exceptions import UsageError
label_desc: Use image node_id 7 for calling a global function with example usage: _enter_pdb(node, excinfo, rep) and returns: rep